Warning filters only work in configuration files and not the command line #8759
Replies: 4 comments
-
Hi @FelixBenning, I cannot try exactly your case, but this simple example works for me: import warnings
def test():
warnings.warn(DeprecationWarning("my warning")) [tool.pytest.ini_options]
filterwarnings = ["ignore:my warning"]
Commenting out [tool.pytest.ini_options]
#filterwarnings = ["ignore:my warning"]
But now passing
I suspect your problem might be related to the shell escaping the Otherwise, please provide a minimal reproducible example so we can take a look. |
Beta Was this translation helpful? Give feedback.
-
I have tried |
Beta Was this translation helpful? Give feedback.
-
Please try with |
Beta Was this translation helpful? Give feedback.
-
A few things to keep in mind:
A few tips:
Examle, given the warning:
You can ignore it using a [pytest]
filterwarnings =
ignore:the imp module is deprecated:DeprecationWarning:flatbuffers\.compat:19 This example is very specific -- generally you want to omit the line number at the end and possibly other fields. Other filters that work that you can put in the
Some examples that don't work:
If you want to use
Some examples with
Hope this helps whoever runs into similar issues! |
Beta Was this translation helpful? Give feedback.
-
works, but the command line version does not
Output of pip freeze
pytest and operating system versions:
See also Comment below a StackOverflow Answer
Beta Was this translation helpful? Give feedback.
All reactions