Leave out the test of each failing subtest, which pytest 9.2 reports only as SUBFAILED<description> <test>
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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"), [])
|
||||
|
||||
Reference in New Issue
Block a user