Skip to content

Preserve session and module teardown when fixture teardown fails#319

Open
emmanuel-ferdman wants to merge 2 commits intopytest-dev:masterfrom
emmanuel-ferdman:master
Open

Preserve session and module teardown when fixture teardown fails#319
emmanuel-ferdman wants to merge 2 commits intopytest-dev:masterfrom
emmanuel-ferdman:master

Conversation

@emmanuel-ferdman
Copy link

PR Summary

When a fixture's teardown raised an exception and reruns were enabled, session and module scoped fixture teardowns were never executed. The cleanup logic was clearing the entire setup state stack instead of just removing the failed test item, which inadvertently removed the finalizers for higher-scoped fixtures. This PR fixes that by only removing the current test item from the stack.

Fixes #314.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@icemac
Copy link
Contributor

icemac commented Feb 6, 2026

Hi @emmanuel-ferdman! Thank you for the PR. I really like it. Could you please a an entry in the change log, that would make it perfect.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@emmanuel-ferdman
Copy link
Author

@icemac Added. thanks for the review!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

teardown incomplete if fixture raises an exception

2 participants