Fix --last-failed with unittest subtests#14584
Open
sjh9714 wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes #14575.
Failed
unittest.TestCase.subTestreports could be overwritten by later passing subtest or parent call reports in the last-failed cache, so--last-faileddid not rerun the parent test. This keeps the parent node marked as failed when any subtest report fails, without changing the existing unittest subtest terminal summary behavior.Changes
cache/lastfailedentries for tests that emitted a failedSubtestReport.--last-failedwithunittest.TestCase.subTest.Testing
python -m pytest testing/test_subtests.py::TestUnittestSubTest::test_last_failed -qpython -m pytest testing/test_subtests.py::test_subtests_last_failed_step_wise -qpython -m pytest testing/test_subtests.py::TestUnittestSubTest::test_last_failed testing/test_subtests.py::test_subtests_last_failed_step_wise -qpython -m ruff check src/_pytest/cacheprovider.py testing/test_subtests.pypython -m pytest testing/test_subtests.py -qpython -m pytest testing/test_cacheprovider.py::TestLastFailed testing/test_cacheprovider.py::test_cache_show -q--last-faileddoes not (always?) see tests which failed in a subtest #14575: after an initial failing run,python -m pytest --lf --lfnf=none -qreran the parentunittesttest and failed on the same subtests instead of deselecting everything.Note: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.