-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warnings: support for logging.captureWarnings #2449
Comments
Thanks for posting the issue @blueyed. IIUC the idea is for pytest to no longer capture warnings if Just to make sure I understand the issue: if you disable the warnings plugin using |
Yes, and yes. It is really a corner case, and I am going to remove this from the affected project anyway, but rather rely on what filtering |
Would it be sufficient to mention this as a blurb in the docs, or do you feel we need additional support in the code? |
Don't let this hold back a release, not even for the blurb in the docs, please. I will have to think myself (and would appreciate any input of course) about how this should get handled / documented: after all you want to filter warnings by redirecting them through The issue here is that |
Docs should not hold a release, given that they are published directly from
I think just documenting this use case in |
Moved from #2445 (comment):
The warnings plugin does not handle the case where the logging module's
captureWarnings
mechanism is used to route warnings through the logging module, and therefore allows to filter them:logging.captureWarnings
monkeypatcheswarnings.showwarning
(in Python 3.6) to log them instead (as a warning).pytest could maybe check if
logging._warnings_showwarning is not None
to detect if warnings are supposed to go throughlogging
.With or without this in setup.cfg:
This mechanism is useful if you want to have fine-grained support on filtering, e.g. based on some (dynamic) path in the warning message.
I am not sure if it is worth the effort to do something in this regard, and if so what the best option would be: maybe transferring it into a log record and see if the
py.warnings
handlers would filter them?The text was updated successfully, but these errors were encountered: