Skip to content

Fix: warning filters set in pytest_configure being ignored#14346

Open
harsh21234i wants to merge 1 commit intopytest-dev:mainfrom
harsh21234i:fix-warning-configure-filters
Open

Fix: warning filters set in pytest_configure being ignored#14346
harsh21234i wants to merge 1 commit intopytest-dev:mainfrom
harsh21234i:fix-warning-configure-filters

Conversation

@harsh21234i
Copy link
Copy Markdown

Fixes issue where warnings configured using warnings.filterwarnings()
inside pytest_configure are ignored.

During the config stage, warnings.catch_warnings() resets the global
warnings filter state, causing user-defined filters to be lost when
pytest applies its own filters.

This change preserves existing filters before applying pytest-configured
filters and restores them afterward, ensuring that user-defined warning
filters behave as expected.

The fix is scoped to issue_config_time_warning to avoid affecting
runtime warning handling and maintains correct precedence between
command-line, ini, and mark-based filters.

All tests pass locally. #13284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant