Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pytest_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,17 @@ def pytest_report_to_serializable(report):
def pytest_report_from_serializable(data):
if data.get("_report_type") == "SubTestReport":
return SubTestReport._from_json(data)


@pytest.hookimpl(tryfirst=True)
def pytest_report_teststatus(report):
if report.when != "call" or not isinstance(report, SubTestReport):
return

outcome = report.outcome
if report.passed:
return outcome, ",", "SUBPASS"
elif report.skipped:
return outcome, "-", "SUBSKIP"
elif outcome == "failed":
return outcome, "u", "SUBFAIL"
22 changes: 11 additions & 11 deletions tests/test_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def test_simple_terminal_verbose(self, simple_script, testdir, mode):
result = testdir.runpytest("-v")
expected_lines = [
"*collected 1 item",
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
"test_simple_terminal_verbose.py::test_foo FAILED *100%*",
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
"test_simple_terminal_verbose.py::test_foo FAILED *100%*",
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo SUBFAIL *100%*",
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo SUBFAIL *100%*",
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
]
else:
Expand Down Expand Up @@ -168,17 +168,17 @@ def test_simple_terminal_verbose(self, simple_script, testdir, runner):
result = testdir.runpytest(simple_script, "-v")
expected_lines = [
"*collected 1 item",
"test_simple_terminal_verbose.py::T::test_foo FAILED *100%*",
"test_simple_terminal_verbose.py::T::test_foo FAILED *100%*",
"test_simple_terminal_verbose.py::T::test_foo SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo PASSED *100%*",
]
else:
pytest.importorskip("xdist")
result = testdir.runpytest(simple_script, "-n1", "-v")
expected_lines = [
"gw0 [1]",
"*gw0*100%* FAILED test_simple_terminal_verbose.py::T::test_foo*",
"*gw0*100%* FAILED test_simple_terminal_verbose.py::T::test_foo*",
"*gw0*100%* SUBFAIL test_simple_terminal_verbose.py::T::test_foo*",
"*gw0*100%* SUBFAIL test_simple_terminal_verbose.py::T::test_foo*",
"*gw0*100%* PASSED test_simple_terminal_verbose.py::T::test_foo*",
]
result.stdout.fnmatch_lines(
Expand Down Expand Up @@ -274,8 +274,8 @@ def test_no_capture(self, testdir):
[
"start test",
"hello stdout A",
"Fhello stdout B",
"Fend test",
"uhello stdout B",
"uend test",
"*__ test (i='A') __*",
"*__ test (i='B') __*",
"*__ test __*",
Expand Down