Support rerunning on subtest errors in pytest 9.0 and newer#330
Open
flyser wants to merge 5 commits into
Open
Conversation
8755a6f to
ee003b3
Compare
Fixes: * Wrong color in the test summary, because pytest would only check the existance, but not the value of the 'failed' key in the tr.stats * Wrong count of the passed subtests
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in pytest-rerunfailures for treating pytest 9+ subtest failures as test failures so the whole test is rerun, addressing the behavior reported in #315.
Changes:
- Detect failed subtests (pytest 9.0+) and trigger reruns even when the main test report is not marked failed.
- Clean up subtest failure state and terminal reporter stats when scheduling a rerun to avoid incorrect final tallies/exit status.
- Add pytest 9+ subtest-focused regression tests and document the feature in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/pytest_rerunfailures.py |
Adds pytest 9 subtest integration, rerun decision logic, and cleanup of subtest-related state/stats across reruns. |
tests/test_pytest_rerunfailures.py |
Adds regression tests for rerunning tests with failing subtests (pytest 9+ only). |
CHANGES.rst |
Documents the new subtest rerun behavior and its pytest 9+ availability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
@flyser Please re-review Copilot's comments. |
Author
|
Hi @icemac, done :) |
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.
This adds subtest support from pytest 9.0 to pytest-rerunfailures. Tests with failing subtests are handled as failed tests and are rerun completely (not the single subtest is run, but the full test). Resolves #315.
For transparency: Note that the _remove_failed_subtest_reports_from_stats() function is AI generated. The rest is human generated ;-)