Skip to content

Commit

Permalink
Passing subtests no longer turn the output yellow (similar to warnings)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed May 13, 2023
1 parent 5bc0a56 commit 654eab5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-------------------
Expand Down
17 changes: 17 additions & 0 deletions pytest_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 654eab5

Please sign in to comment.