diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a7ccd13..736dd8b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) ------------------ diff --git a/pytest_subtests.py b/pytest_subtests.py index c275035..740d38b 100644 --- a/pytest_subtests.py +++ b/pytest_subtests.py @@ -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() @@ -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 @@ -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"