Skip to content

Fix nested caplog.filtering early removal#14284

Open
oaksprout wants to merge 8 commits into
pytest-dev:mainfrom
oaksprout:fix-nested-caplog-filtering
Open

Fix nested caplog.filtering early removal#14284
oaksprout wants to merge 8 commits into
pytest-dev:mainfrom
oaksprout:fix-nested-caplog-filtering

Conversation

@oaksprout
Copy link
Copy Markdown

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.

def test_ini_controls_global_log_level(pytester: Pytester) -> None:
pytester.makepyfile(
"""
pytester.makepyfile("""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what triggered those style changes?

@RonnyPfannschmidt RonnyPfannschmidt added the backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested caplog.filtering usage may remove filters early

3 participants