(
report: TestReport,
config: Config,
)
| 365 | |
| 366 | @hookimpl(tryfirst=True) |
| 367 | def pytest_report_teststatus( |
| 368 | report: TestReport, |
| 369 | config: Config, |
| 370 | ) -> tuple[str, str, str | Mapping[str, bool]] | None: |
| 371 | if report.when != "call": |
| 372 | return None |
| 373 | |
| 374 | quiet = config.get_verbosity(Config.VERBOSITY_SUBTESTS) == 0 |
| 375 | if isinstance(report, SubtestReport): |
| 376 | outcome = report.outcome |
| 377 | description = report._sub_test_description() |
| 378 | |
| 379 | if hasattr(report, "wasxfail"): |
| 380 | if quiet: |
| 381 | return "", "", "" |
| 382 | elif outcome == "skipped": |
| 383 | category = "xfailed" |
| 384 | short = "y" # x letter is used for regular xfail, y for subtest xfail |
| 385 | status = "SUBXFAIL" |
| 386 | # outcome == "passed" in an xfail is only possible via a @pytest.mark.xfail mark, which |
| 387 | # is not applicable to a subtest, which only handles pytest.xfail(). |
| 388 | else: # pragma: no cover |
| 389 | # This should not normally happen, unless some plugin is setting wasxfail without |
| 390 | # the correct outcome. Pytest expects the call outcome to be either skipped or |
| 391 | # passed in case of xfail. |
| 392 | # Let's pass this report to the next hook. |
| 393 | return None |
| 394 | return category, short, f"{status}{description}" |
| 395 | |
| 396 | if report.failed: |
| 397 | 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}" |
| 409 | |
| 410 | else: |
| 411 | failed_subtests_count = config.stash[failed_subtests_key][report.nodeid] |
| 412 | # Top-level test, fail if it contains failed subtests and it has passed. |
| 413 | if report.passed and failed_subtests_count > 0: |
| 414 | report.outcome = "failed" |
| 415 | suffix = "s" if failed_subtests_count > 1 else "" |
| 416 | report.longrepr = f"contains {failed_subtests_count} failed subtest{suffix}" |
| 417 | |
| 418 | return None |
nothing calls this directly
no test coverage detected