Skip to content

Conversation

isra17
Copy link
Contributor

@isra17 isra17 commented Sep 15, 2025

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 #13485

So this PR change the behavior of failed category import to just log a warning and skip the warning entry.

@isra17 isra17 force-pushed the isra/upstream-no-warning-fail branch from 2521fe3 to 1258ad6 Compare September 15, 2025 16:52
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 15, 2025
@isra17 isra17 force-pushed the isra/upstream-no-warning-fail branch from 1258ad6 to 3cbbc5e Compare September 15, 2025 16:53
Copy link
Member

@nicoddemus nicoddemus left a 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.

@isra17 isra17 force-pushed the isra/upstream-no-warning-fail branch 5 times, most recently from 7dd2cbb to 195f5e2 Compare September 18, 2025 13:44
@isra17
Copy link
Contributor Author

isra17 commented Sep 18, 2025

The branch is now green and I addressed all your comments. Thanks for your quick review!

@@ -0,0 +1 @@
Do not fail when a warning category cannot be imported. Log a warning instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@isra17 isra17 force-pushed the isra/upstream-no-warning-fail branch from 17f7b25 to 950e781 Compare September 18, 2025 19:35
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicoddemus nicoddemus merged commit 09ad02c into pytest-dev:main Sep 20, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants