Fix nested caplog.filtering with same filter object by elpolini · Pull Request #14228 · pytest-dev/pytest
Navigation Menu
{{ message }}
pytest-dev / pytest Public
- Notifications You must be signed in to change notification settings
- Fork 3.1k
Open
elpolini wants to merge 1 commit intopytest-dev:mainfrom
Open
Fix nested caplog.filtering with same filter object#14228
elpolini wants to merge 1 commit intopytest-dev:mainfrom
Fix nested caplog.filtering with same filter object#14228
elpolini wants to merge 1 commit intopytest-dev:mainfrom
Conversation
Copy link
Summary
- Fix caplog.filtering so nested use with the same filter object does not remove the outer filter too early.
- Only add/remove the filter when this context manager actually changed handler state.
- Add a regression test for nested caplog.filtering with the same filter instance.
Why
Issue #14189 reports that nested caplog.filtering can unexpectedly remove an active filter, causing logs to leak into capture inside the outer context.
Validation
- python -m pytest -q testing/logging/test_fixture.py -k with_statement_filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment