Leave out the test of each failing subtest, which pytest 9.2 reports only as SUBFAILED<description> <test>

This commit is contained in:
2026-11-11 19:22:10 +01:00
parent 79e8ce1368
commit 42a637d718
2 changed files with 9 additions and 4 deletions
+5 -3
View File
@@ -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]