Reputation: 3156
I'm trying out pytest
for the first time. How do I suppress warnings issued about other peoples code that my code depends on without suppressing warnings about my own code?
Right now I have this in my pytest.ini
so I don't have to see pytest warn me about some deprecation on the jsonschema
package that I'm using.
[pytest]
filterwarnings =
ignore::DeprecationWarning
But now if I write anything in my own code that should fire of a deprecation warning I'll miss it.
Upvotes: 9
Views: 1908
Reputation: 2203
The syntax for pytest-warning is action:message:category:module:lineno
. You can use this config for ignoring only jsonschema:
[pytest]
filterwarnings =
ignore::DeprecationWarning:jsonschema
You can also use regex in those fields. If you want to exclude all warnings except yours:
[pytest]
filterwarnings =
ignore::DeprecationWarning:!yourtestmodule
Pytest uses the same filterwarning as python. You can learn more about python warnings here: https://docs.python.org/3/library/warnings.html#warning-filter
Source: https://github.com/fschulze/pytest-warnings/blob/master/pytest_warnings/__init__.py#L18
Upvotes: 9