Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

0.10.0 (UNRELEASED)
-------------------

* Added experimental support for suppressing subtest output dots in non-verbose mode with ``--no-subtests-shortletter``.

0.9.0 (2022-10-28)
------------------

Expand Down
22 changes: 18 additions & 4 deletions pytest_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
from _pytest.unittest import TestCaseFunction


def pytest_addoption(parser):
group = parser.getgroup("subtests")
group.addoption(
"--no-subtests-shortletter",
action="store_true",
dest="no_subtests_shortletter",
default=False,
help="Disables subtest output 'dots' in non-verbose mode (EXPERIMENTAL)",
)


@attr.s
class SubTestContext:
msg = attr.ib()
Expand Down Expand Up @@ -227,7 +238,7 @@ def pytest_report_from_serializable(data):


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

Expand All @@ -236,8 +247,11 @@ def pytest_report_teststatus(report):

outcome = report.outcome
if report.passed:
return f"subtests {outcome}", ",", "SUBPASS"
short = "" if config.option.no_subtests_shortletter else ","
return f"subtests {outcome}", short, "SUBPASS"
elif report.skipped:
return outcome, "-", "SUBSKIP"
short = "" if config.option.no_subtests_shortletter else "-"
return outcome, short, "SUBSKIP"
elif outcome == "failed":
return outcome, "u", "SUBFAIL"
short = "" if config.option.no_subtests_shortletter else "u"
return outcome, short, "SUBFAIL"