Skip to content

[IMPROVEMENT] Resolve warnings from tests (And classify them as error after) #325

@mgovers

Description

@mgovers

Describe the problem
Currently, we use warnings to catch, suppress and raise warnings in testing, e.g., using

with warnings.catch_warnings():
    warnings.simplefilter("error")

It would be much cleaner to use pytest's filterwarning, either as a decorator

@pytest.mark.filterwarnings("error")

or even at the global level, using

# pyproject.toml
[tool.pytest.ini_options]
filterwarnings = ["error"]

However, unfortunately, enabling that causes new warnings to pop up. That is a consequence of other things we or dependencies are not doing nicely, so they really are real warnings.

Raised in #320 (comment)

Its much cleaner to use @pytest.mark.filterwarnings("error") decorator instead

Improvement proposal

This issue consists of multiple steps:

  • Replace all with warnings.catch_warnings(): warnings.simplefilter("error") blocks with @pytest.mark.filterwarnings("error") decorators
    • Either fix or explicitly suppress all new errors that pop up
    • Create pull + merge request
  • [after the previous step is resolved] Replace all @pytest.mark.filterwarnings("error") decorators with one global setting in the pyproject.toml (see above)
    • Either fix or explicitly suppress all new errors that pop up
    • Create pull + merge request

Split from #320 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIndicates a good issue for first-time contributorsimprovementExisting functionality, but better, faster, stronger

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions