Skip to content

Commit f27708b

Browse files
committed
Simplify pytest_report_teststatus for subtests
1 parent f081bfb commit f27708b

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

src/_pytest/subtests.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,8 @@ def pytest_report_teststatus(
380380
if quiet:
381381
return "", "", ""
382382
elif outcome == "skipped":
383-
category = "xfailed"
384-
short = "y" # x letter is used for regular xfail, y for subtest xfail
385-
status = "SUBXFAIL"
383+
# x letter is used for regular xfail, y for subtest xfail
384+
return "xfailed", "y", f"SUBXFAIL{description}"
386385
# outcome == "passed" in an xfail is only possible via a @pytest.mark.xfail mark, which
387386
# is not applicable to a subtest, which only handles pytest.xfail().
388387
else: # pragma: no cover
@@ -391,21 +390,15 @@ def pytest_report_teststatus(
391390
# passed in case of xfail.
392391
# Let's pass this report to the next hook.
393392
return None
394-
return category, short, f"{status}{description}"
395393

396394
if report.failed:
397395
return outcome, "u", f"SUBFAILED{description}"
398-
else:
399-
if report.passed:
400-
if quiet:
401-
return "", "", ""
402-
else:
403-
return f"subtests {outcome}", "u", f"SUBPASSED{description}"
404-
elif report.skipped:
405-
if quiet:
406-
return "", "", ""
407-
else:
408-
return outcome, "-", f"SUBSKIPPED{description}"
396+
elif quiet:
397+
return "", "", ""
398+
elif report.passed:
399+
return f"subtests {outcome}", "u", f"SUBPASSED{description}"
400+
elif report.skipped:
401+
return outcome, "-", f"SUBSKIPPED{description}"
409402

410403
else:
411404
failed_subtests_count = config.stash[failed_subtests_key][report.nodeid]

0 commit comments

Comments
 (0)