Skip to content

Commit

Permalink
Include sub-test details in pytest -v (#88)
Browse files Browse the repository at this point in the history
Interim solution to #6.

Fix #6 

---------

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
  • Loading branch information
mauvilsa and nicoddemus authored May 3, 2023
1 parent 77bb669 commit 5bc0a56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

UNRELEASED
----------

* Now the ``msg`` contents of a subtest is displayed when running pytest with ``-v`` (`#6`_).

.. _#6: https://github.com/pytest-dev/pytest-subtests/issues/6

0.10.0 (2022-02-15)
-------------------

Expand Down
7 changes: 4 additions & 3 deletions pytest_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,13 @@ def pytest_report_teststatus(report, config):
return None

outcome = report.outcome
description = report.sub_test_description()
if report.passed:
short = "" if config.option.no_subtests_shortletter else ","
return f"subtests {outcome}", short, "SUBPASS"
return f"subtests {outcome}", short, f"{description} SUBPASS"
elif report.skipped:
short = "" if config.option.no_subtests_shortletter else "-"
return outcome, short, "SUBSKIP"
return outcome, short, f"{description} SUBSKIP"
elif outcome == "failed":
short = "" if config.option.no_subtests_shortletter else "u"
return outcome, short, "SUBFAIL"
return outcome, short, f"{description} SUBFAIL"
14 changes: 7 additions & 7 deletions tests/test_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,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 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 [[]custom[]] (i=0) SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=1) SUBFAIL *100%*",
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=2) SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=3) SUBFAIL *100%*",
"test_simple_terminal_verbose.py::test_foo [[]custom[]] (i=4) SUBPASS *100%*",
"test_simple_terminal_verbose.py::test_foo PASSED *100%*",
]
else:
Expand Down Expand Up @@ -193,8 +193,8 @@ 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 SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo [[]custom[]] (i=1) SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo [[]custom[]] (i=3) SUBFAIL *100%*",
"test_simple_terminal_verbose.py::T::test_foo PASSED *100%*",
]
else:
Expand Down

0 comments on commit 5bc0a56

Please sign in to comment.