Skip to content

Commit 5bc0a56

Browse files
mauvilsanicoddemus
andauthored
Include sub-test details in pytest -v (#88)
Interim solution to #6. Fix #6 --------- Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
1 parent 77bb669 commit 5bc0a56

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
UNRELEASED
5+
----------
6+
7+
* Now the ``msg`` contents of a subtest is displayed when running pytest with ``-v`` (`#6`_).
8+
9+
.. _#6: https://github.com/pytest-dev/pytest-subtests/issues/6
10+
411
0.10.0 (2022-02-15)
512
-------------------
613

pytest_subtests.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,13 @@ def pytest_report_teststatus(report, config):
246246
return None
247247

248248
outcome = report.outcome
249+
description = report.sub_test_description()
249250
if report.passed:
250251
short = "" if config.option.no_subtests_shortletter else ","
251-
return f"subtests {outcome}", short, "SUBPASS"
252+
return f"subtests {outcome}", short, f"{description} SUBPASS"
252253
elif report.skipped:
253254
short = "" if config.option.no_subtests_shortletter else "-"
254-
return outcome, short, "SUBSKIP"
255+
return outcome, short, f"{description} SUBSKIP"
255256
elif outcome == "failed":
256257
short = "" if config.option.no_subtests_shortletter else "u"
257-
return outcome, short, "SUBFAIL"
258+
return outcome, short, f"{description} SUBFAIL"

tests/test_subtests.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ def test_simple_terminal_verbose(self, simple_script, testdir, mode):
4343
result = testdir.runpytest("-v")
4444
expected_lines = [
4545
"*collected 1 item",
46-
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
47-
"test_simple_terminal_verbose.py::test_foo SUBFAIL *100%*",
48-
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
49-
"test_simple_terminal_verbose.py::test_foo SUBFAIL *100%*",
50-
"test_simple_terminal_verbose.py::test_foo SUBPASS *100%*",
46+
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=0) SUBPASS *100%*",
47+
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=1) SUBFAIL *100%*",
48+
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=2) SUBPASS *100%*",
49+
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=3) SUBFAIL *100%*",
50+
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=4) SUBPASS *100%*",
5151
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
5252
]
5353
else:
@@ -193,8 +193,8 @@ def test_simple_terminal_verbose(self, simple_script, testdir, runner):
193193
result = testdir.runpytest(simple_script, "-v")
194194
expected_lines = [
195195
"*collected 1 item",
196-
"test_simple_terminal_verbose.py::T::test_foo SUBFAIL *100%*",
197-
"test_simple_terminal_verbose.py::T::test_foo SUBFAIL *100%*",
196+
"test_simple_terminal_verbose.py::T::test_foo [[]custom[]] (i=1) SUBFAIL *100%*",
197+
"test_simple_terminal_verbose.py::T::test_foo [[]custom[]] (i=3) SUBFAIL *100%*",
198198
"test_simple_terminal_verbose.py::T::test_foo PASSED *100%*",
199199
]
200200
else:

0 commit comments

Comments
 (0)