Fix nested caplog.filtering early removal by oaksprout · Pull Request #14284 · pytest-dev/pytest

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@oaksprout

Copy link

Closes #14189. Nested caplog.filtering usage was eagerly removing filters when the inner context manager exited, even if the filter was already present from the outer context manager. This PR ensures the filter is only removed if it wasn't already present when the context manager was entered.

Closes pytest-dev#14189 by checking if the filter is already present before adding or removing it.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided

(automation) changelog entry is part of PR

label

Mar 13, 2026

themavik

This comment was marked as spam.

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

Reviewers

1 more reviewer

@themavik themavik themavik left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

bot:chronographer:provided

(automation) changelog entry is part of PR

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Nested caplog.filtering usage may remove filters early

2 participants

@oaksprout @themavik