Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Changelog
- Fix missing teardown for session and module scoped fixtures when fixture teardown fails.
Fixes `#314 <https://github.com/pytest-dev/pytest-rerunfailures/issues/314>`_.

- Clear fixture finalizers when removing cached results from failed fixtures
to fix compatibility with pytest >= 9, which asserts that ``_finalizers`` is
empty before executing a fixture.
Fixes `#323 <https://github.com/pytest-dev/pytest-rerunfailures/issues/323>`_.


16.1 (2025-10-10)
-----------------
Expand Down
5 changes: 5 additions & 0 deletions src/pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ def _remove_cached_results_from_failed_fixtures(item):
result, _, err = getattr(fixture_def, cached_result)
if err: # Deleting cached results for only failed fixtures
setattr(fixture_def, cached_result, None)
# Clear finalizers registered during the failed execution
# so the fixture can be re-executed cleanly (pytest >= 9
# asserts _finalizers is empty before executing a fixture).
if hasattr(fixture_def, "_finalizers"):
fixture_def._finalizers.clear()


def _remove_failed_setup_state_from_session(item):
Expand Down
Loading