-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
config: Do not fail if a warning filter category cannot be imported #13732
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
config: Do not fail if a warning filter category cannot be imported #13732
Conversation
2521fe3
to
1258ad6
Compare
1258ad6
to
3cbbc5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @isra17 for the contribution!
Other than the comments I left, please look at the test failure: that test is verifying that we error out if the warnings filter could not be imported, which is exactly what you have changed here. I think you only need to remove that case from the paramatrization.
7dd2cbb
to
195f5e2
Compare
The branch is now green and I addressed all your comments. Thanks for your quick review! |
changelog/13732.improvement.rst
Outdated
@@ -0,0 +1 @@ | |||
Do not fail when a warning category cannot be imported. Log a warning instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not fail when a warning category cannot be imported. Log a warning instead. | |
Previously, when filtering warnings, pytest would fail if the filter referenced a class that could not be imported. Now, this only outputs a message indicating the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also apply that change? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
17f7b25
to
950e781
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
We stumbled into an issue using tools like pants that will generate test environment with minimal dependencies. If used with warning filters with categories from third-party library, pytest is going to fail for any test without this third-party. This is unecessary and any workaround in
conftest.py
is impossible due to #13485So this PR change the behavior of failed category import to just log a warning and skip the warning entry.