diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 647c3ee..cd7a516 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,9 +4,13 @@ CHANGELOG UNRELEASED ---------- +* Passed subtests no longer turn the pytest output to yellow (as if warnings have been issued) (`#86`_). Thanks to `Andrew-Brock`_ for providing the solution. * 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 +.. _#86: https://github.com/pytest-dev/pytest-subtests/issues/86 + +.. _`Andrew-Brock`: https://github.com/Andrew-Brock 0.10.0 (2022-02-15) ------------------- diff --git a/pytest_subtests.py b/pytest_subtests.py index 1ee4fb2..11c1748 100644 --- a/pytest_subtests.py +++ b/pytest_subtests.py @@ -97,6 +97,23 @@ def pytest_configure(config): TestCaseFunction.addSubTest = _addSubTest TestCaseFunction.failfast = False + # Hack (#86): the terminal does not know about the "subtests" + # status, so it will by default turn the output to yellow. + # This forcibly adds the new 'subtests' status. + import _pytest.terminal + + _pytest.terminal.KNOWN_TYPES = _pytest.terminal.KNOWN_TYPES + tuple( + f"subtests {outcome}" for outcome in ("passed", "failed", "skipped") + ) + + _pytest.terminal._color_for_type.update( + { + f"subtests {outcome}": _pytest.terminal._color_for_type[outcome] + for outcome in ("passed", "failed", "skipped") + if outcome in _pytest.terminal._color_for_type + } + ) + def pytest_unconfigure(): if hasattr(TestCaseFunction, "addSubTest"):