summaryrefslogtreecommitdiff
path: root/testing/test_terminal.py
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-04-04 14:00:15 +0300
committerRan Benita <ran@unusedvar.com>2020-04-04 17:27:59 +0300
commit1ce30fd38f9e58593f3605a2fcf5a0e9f185cb03 (patch)
treea7f7690e33adec4de1fbea4823a1dae87d4b7cda /testing/test_terminal.py
parente01dcbf3235188c64d8aa3b9cdc014efbc29e15d (diff)
downloadpytest-1ce30fd38f9e58593f3605a2fcf5a0e9f185cb03.tar.gz
Document the pytest_report_teststatus hook better and test uncovered functionality
This hook has some functionality to provide explicit markup for the test status. It seemed unused and wasn't tested, so I was tempted to remove it, but I found that the pytest-rerunfailures plugin uses it, so document it and add a test instead.
Diffstat (limited to 'testing/test_terminal.py')
-rw-r--r--testing/test_terminal.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/test_terminal.py b/testing/test_terminal.py
index 38ca1957a..88d564519 100644
--- a/testing/test_terminal.py
+++ b/testing/test_terminal.py
@@ -306,6 +306,29 @@ class TestTerminal:
tr.rewrite("hey", erase=True)
assert f.getvalue() == "hello" + "\r" + "hey" + (6 * " ")
+ def test_report_teststatus_explicit_markup(
+ self, testdir: Testdir, color_mapping
+ ) -> None:
+ """Test that TerminalReporter handles markup explicitly provided by
+ a pytest_report_teststatus hook."""
+ testdir.monkeypatch.setenv("PY_COLORS", "1")
+ testdir.makeconftest(
+ """
+ def pytest_report_teststatus(report):
+ return 'foo', 'F', ('FOO', {'red': True})
+ """
+ )
+ testdir.makepyfile(
+ """
+ def test_foobar():
+ pass
+ """
+ )
+ result = testdir.runpytest("-v")
+ result.stdout.fnmatch_lines(
+ color_mapping.format_for_fnmatch(["*{red}FOO{reset}*"])
+ )
+
class TestCollectonly:
def test_collectonly_basic(self, testdir):