Repository navigation
Replies: 2 comments
|
Yes: the module field in [pytest]
filterwarnings =
ignore::DeprecationWarning
default::DeprecationWarning:^myapp(\.|$)Replace Keep pytest's warnings plugin enabled for this; remove I checked this on Python 3.14 / pytest 9.2.0 with warnings emitted in Prepared with Codex assistance; the config behavior above was checked locally. |
|
The [pytest]
filterwarnings =
ignore::DeprecationWarning
default::DeprecationWarning:myapp(\..*)?$Later lines win, so this silences DeprecationWarnings everywhere, then turns them back on for your package. Use If a dep still leaks through, print — |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have so far been using Python code to configure warning filters (rather than
$PYTHONWARNINGS,-W, orfilterwarningsin pytest.ini) because this enables me to use regular expression to select modules.My use case is that I would like to see all Deprecation warnings that can be fixed in the application that I'm testing, but not in modules that I do not control. With regular expressions, I can just match on the top-level module name. Without regular expression, I need to hardcode every module and sub-module.
Unfortunately, I have just discovered that pytest has been messing with my warning configuration despite me using the
-p no:warningsflag (see #10847 for a related problem).Is there any way to use pytest's own warnings facilities with regular expressions for the module?
All reactions