Repository navigation
Report fixture teardown errors before interrupted sessions finish - #15357
Open
iamabhisheknag wants to merge 1 commit into
Open
iamabhisheknag wants to merge 1 commit into
iamabhisheknag wants to merge 1 commit into
Conversation
Run teardown reporting before reraising setup/call interruptions. Preserve requested exit codes and correct interrupted JUnit testcase counts. Include regression coverage, changelog, and author credit.
iamabhisheknag
force-pushed
the
codex/report-teardown-on-interrupt
branch
from
November 9, 2026 01:30
2e0d878 to
4563524
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8750.
When
pytest.exit()or a keyboard interrupt occurs during setup or a test call, fixture teardown currently happens during session shutdown. A teardown failure can then escape as an unhandled exception after the JUnit XML has been written, masking the requested exit code and omitting the error from the report.Run the normal teardown reporting path before reraising the interruption, releasing fixtures of every scope. Preserve the requested exit status and include teardown errors in the reports. Also distinguish JUnit reporters created only for setup timing from reporters with an actual outcome, so an interrupted call followed by a teardown error is counted once.
Validation: all 12 new subprocess regression cases fail on unpatched main and pass with the fix. They cover setup/call interruptions, function/session fixture scopes,
pytest.exit, explicit status 99, andKeyboardInterrupt. Relevant runner, main, terminal, JUnit, fixture, capture, and logging tests: 963 passed, 3 skipped, 5 xfailed. Mypy passes on the three changed Python files; pinned Ruff checks and formatting pass. The full suite and full pre-commit suite have not been run.AI disclosure: the reproduction, patch, tests, and this description were prepared with AI assistance. The account holder confirmed review and understanding of the change and authorized upstream submission. No production incident is claimed.