Repository navigation
Replies: 3 comments
|
yeah, you're reading it right. This is basically the same split as #8759 (comment)
For CLI you'd need the concrete module name, or keep the package-wide regex case in config. |
This comment was marked as low quality.
This comment was marked as low quality.
|
There is also a way to pass the regex through the command line: override the For Bash: python -m pytest -o $'filterwarnings=error\nignore::UserWarning:^tests\\.'This sets two config filters: turn warnings into errors, then ignore The distinction you found is intentional: One correction to the earlier workaround: I checked on Python 3.12.10 / pytest 9.1.1 with a warning emitted in References: warning filter syntax and precedence, overriding config options. Prepared with AI assistance; the behavior above was checked locally. |
Uh oh!
There was an error while loading. Please reload this page.
I’m trying to understand pytest’s warning filter behavior for CLI
-Woptions vsfilterwarningsin config.This works in
tox.ini:But the equivalent CLI form does not seem to work:
python -m pytest -W error -W "ignore::UserWarning:tests.*"while this DOES work:
python -m pytest -W error -W "ignore::UserWarning:tests.test_utils"Looking at
_pytest/config/__init__.py, it appears CLI-Wfilters are parsed withescape=True:which seems to force exact module matching for CLI filters.
Am I understanding correctly that wildcard/regex module matching is intentionally unsupported for CLI
-W, and only supported in config-filefilterwarnings?All reactions