From 42a637d718738b71a17c4d1340d096f689399309 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 11 Nov 2026 19:22:10 +0100 Subject: [PATCH] Leave out the test of each failing subtest, which pytest 9.2 reports only as SUBFAILED --- bin/mutate_changes/mutmut_setup.py | 8 +++++--- bin/mutate_changes/test_mutate_changes.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/mutate_changes/mutmut_setup.py b/bin/mutate_changes/mutmut_setup.py index 1dff24a7..5c32e260 100644 --- a/bin/mutate_changes/mutmut_setup.py +++ b/bin/mutate_changes/mutmut_setup.py @@ -6,8 +6,9 @@ import re from failure import Failure SUMMARY = re.compile(r"^=+ short test summary info =+$", re.MULTILINE) -# A test pytest's short summary reports as failed or erroring; its message, where one fits, follows " - ". -REPORTED = re.compile(r"^(?:ERROR|FAILED) (\S.*?)(?: - .*)?$", re.MULTILINE) +# A test pytest's short summary reports as failed or erroring; its message, where one fits, follows " - ". A failed subtest's line +# names its test after a description in [] or (), which may hold spaces, and pytest reports no line for the test itself. +REPORTED = re.compile(r"^(?:(?:ERROR|FAILED) (\S.*?)|SUBFAILED.*?[\])] (\S+::\S+))(?: - .*)?$", re.MULTILINE) class CaseKept(configparser.ConfigParser): @@ -49,4 +50,5 @@ def left_out(output: str) -> list[str]: summary = SUMMARY.split(output) if len(summary) < 2: return [] - return [f"--deselect={nodeid}" if "::" in nodeid else f"--ignore={nodeid}" for nodeid in REPORTED.findall(summary[-1])] + nodeids = dict.fromkeys(test or subtests_test for test, subtests_test in REPORTED.findall(summary[-1])) + return [f"--deselect={nodeid}" if "::" in nodeid else f"--ignore={nodeid}" for nodeid in nodeids] diff --git a/bin/mutate_changes/test_mutate_changes.py b/bin/mutate_changes/test_mutate_changes.py index be779391..f7b982ca 100644 --- a/bin/mutate_changes/test_mutate_changes.py +++ b/bin/mutate_changes/test_mutate_changes.py @@ -98,10 +98,13 @@ class MutmutSetup(unittest.TestCase): FAILED repo_checks/test_repo_checks.py::Repo::test_a - AssertionError: x - y ERROR larv_review/test_larv_review.py - FileNotFoundError: SKILL.md FAILED a/test_b.py::T::test_c + SUBFAILED[['--jobs', '0']] a/test_d.py::T::test_e - AssertionError: 1 != 0 + SUBFAILED[['--jobs']] a/test_d.py::T::test_e - AssertionError: 1 != 0 + SUBFAILED[m] (path='/dev/zero', kind='a b') a/test_d.py::T::test_f 2 failed, 1 error in 3.10s failed to collect stats. runner returned 1 """) - self.assertEqual(left_out(output), ["--deselect=repo_checks/test_repo_checks.py::Repo::test_a", "--ignore=larv_review/test_larv_review.py", "--deselect=a/test_b.py::T::test_c"]) + self.assertEqual(left_out(output), ["--deselect=repo_checks/test_repo_checks.py::Repo::test_a", "--ignore=larv_review/test_larv_review.py", "--deselect=a/test_b.py::T::test_c", "--deselect=a/test_d.py::T::test_e", "--deselect=a/test_d.py::T::test_f"]) def test_left_out_is_empty_without_a_summary(self): self.assertEqual(left_out("failed to collect stats. runner returned 1\n"), [])