Skip to content

fix(fixtures): register finalizer for indirectly promoted fixtures (fixes #15436) - #15438

Closed
ghanashyam03 wants to merge 1 commit into
pytest-dev:mainfrom
ghanashyam03:fix/issue-15436-indirect-promoted-fixture-scope
Closed

ghanashyam03 wants to merge 1 commit into
pytest-dev:mainfrom
ghanashyam03:fix/issue-15436-indirect-promoted-fixture-scope

Conversation

@ghanashyam03

Copy link
Copy Markdown

Summary

Updated FixtureDef.execute to register the finalizer with requested fixtures when either self._scope or request._scope is not Scope.Function.

Motivation

Fixes #15436. When a function-scoped fixture is promoted to a wider scope via indirect parametrization (such as @pytest.mark.parametrize("child", ..., indirect=True, scope="module")), checking only self._scope is not Scope.Function skipped adding the child finalizer to requested parent fixtures. When a requested parametrized fixture changed parameters, the child fixture was not finalized and remained cached holding stale or closed parent resources across tests.

Testing

  • Added regression test test_indirect_promoted_fixture_invalidated_by_param_change in testing/python/fixtures.py.
  • Ran pytest testing/python/fixtures.py with all 247 tests passing (2 xfailed, 0 failures).
  • Ran ruff check src/_pytest/fixtures.py testing/python/fixtures.py with 0 errors.
  • Added changelog fragment changelog/15436.bugfix.rst.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 23, 2026

Copy link
Copy Markdown
Member

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Closing as unattended AI. This account opens about one agent-generated "fixes #N" PR per weekday across unrelated projects, at the same clock times, with no AI disclosure. This one copies the fix proposed in the #15436 body and its repro as the test, and adds nothing of its own. The fix lands in #15439.

Our AI policy: https://github.com/pytest-dev/pytest/blob/main/CONTRIBUTING.rst. If you want to work on an issue, comment on it first in your own words and say what you understand and plan to do.


Generated by Claude Code

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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Indirectly promoted fixture keeps a finalized parent after #15224

2 participants