No longer override existing warning filters during warnings capture#2445
Conversation
c6774cc to
db8d83a
Compare
|
LGTM as-is - and with |
|
@The-Compiler would you do the honors of merging it then? 😁 |
|
What still seems to be problematic is: logging.captureWarnings(True)
logging.getLogger('py.warnings').addFilter(filter_deprecation_warnings)With or without this in setup.cfg: [tool:pytest]
filterwarnings =
once::DeprecationWarning
once::PendingDeprecationWarningI want to use this method to filter out DeprecationWarnings based on where they are coming from. |
|
@blueyed thanks for the feedback. Can you provide more info about what you intend with that? I'm not familiar with Also, do you feel this should block a new release? And do you have a suggestion on how to implement what you want in regards to logging vs warnings? (Sorry for leaving this questions here, just that I have to leave for a meeting and will be out for a few hours) |
|
@nicoddemus |
db8d83a to
f591c6d
Compare
|
Rebased and updated to add a news fragment. 👍 |
|
Thanks @RonnyPfannschmidt. Hmmm that feels like some additional things are still needed. @blueyed do you feel this should hold the release or is something we can tackle afterwards without changing current behavior? My feeling is the former, but would like to hear your opinion first. |
|
I think it should not hold back a release probably, since it fixes more crucial things already. As for |
Thanks! Would you mind opening a separate issue for the logging and warning support? We can move this discussion there. 👍 |
|
|
||
|
|
||
| Starting from version ``3.1``, pytest now automatically catches all warnings during test execution | ||
| and displays them at the end of the session:: |
There was a problem hiding this comment.
*except for DeprecationWarning and PendingDeprecationWarning
changelog/2430.bugfix
Outdated
| @@ -0,0 +1,4 @@ | |||
| pytest warning capture no longer override existing warning filters. The previous | |||
changelog/2430.bugfix
Outdated
| @@ -0,0 +1,4 @@ | |||
| pytest warning capture no longer override existing warning filters. The previous | |||
| behaviour would override all filters and caused regressions in test suites which configure warning | |||
| filters to match their needs. Note as a side-effect of this is that ``DeprecationWarning`` | |||
f591c6d to
32e2642
Compare
|
Thanks @blueyed, applied all your suggestions. 👍 Unless someone else tells otherwise, I will merge this as soon as CI passes again. Thanks everyone for the reviews. |
|
I think this might be doing too much? pytest 3.1.1 is silencing ResourceWarnings by default now which is a pity. In any case it seems at odds with the docs? I hope I’ve reverted to the old behavior by using: filterwarnings =
once::Warning |
In the end it was possible to actually fix the existing behavior. I checked and it no longer breaks SQLAlchemy test suite which was the original post on #2430.
As a downside/side-effect, this no longer automatically captures deprecation warnings because we want to play safe and don't try to mess the existing filters, but I believe we can review this in the future if we like.
Fix #2430