Fix nested caplog.filtering early removal#4
Open
yashwant86 wants to merge 8 commits intomainfrom
Open
Conversation
Closes pytest-dev#14189 by checking if the filter is already present before adding or removing it.
for more information, see https://pre-commit.ci
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
Nested Filter Removal Fixsrc/_pytest/logging.py |
Fixes caplog.filtering context manager to detect and preserve pre-existing filters, preventing premature removal when nesting contexts or when the same filter is already registered. |
Test Coverage & Formattingtesting/logging/test_fixture.py |
Adds two new test cases for nested filtering and pre-existing filter scenarios; reformats multi-line makepyfile/makeini calls to single-line syntax for consistency. |
Changelogchangelog/14189.bugfix.rst |
Documents bugfix for nested caplog.filtering filter removal issue. |
Sequence Diagram
sequenceDiagram
participant Test
participant Handler
participant Filter
Test->>Handler: addFilter(F) [outer context]
Handler->>Filter: register
Test->>Handler: addFilter(F) [inner context]
Note over Handler: F already in filters
Test->>Handler: removeFilter(F) [inner exit]
Note over Handler: F still present (not removed)
Test->>Handler: removeFilter(F) [outer exit]
Handler->>Filter: unregister
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
Author
|
/review --force |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of pytest-dev#14284
Summary by MergeMonkey