terminal: when the skip/xfail is empty, don't show it as "()"

Avoid showing a line like

    x.py::test_4 XPASS ()   [100%]

which looks funny.
This commit is contained in:
Ran Benita 2020-12-12 22:09:00 +02:00
parent 59bd0f6912
commit 3302ff9949
2 changed files with 6 additions and 1 deletions

View File

@ -554,7 +554,7 @@ class TerminalReporter:
) )
reason = _get_raw_skip_reason(rep) reason = _get_raw_skip_reason(rep)
reason_ = _format_trimmed(" ({})", reason, available_width) reason_ = _format_trimmed(" ({})", reason, available_width)
if reason_ is not None: if reason and reason_ is not None:
self._tw.write(reason_) self._tw.write(reason_)
if self._show_progress_info: if self._show_progress_info:
self._write_progress_information_filling_space() self._write_progress_information_filling_space()

View File

@ -362,6 +362,10 @@ class TestTerminal:
@pytest.mark.xfail(reason="789") @pytest.mark.xfail(reason="789")
def test_3(): def test_3():
assert False assert False
@pytest.mark.xfail(reason="")
def test_4():
assert False
""" """
) )
result = pytester.runpytest("-v") result = pytester.runpytest("-v")
@ -370,6 +374,7 @@ class TestTerminal:
"test_verbose_skip_reason.py::test_1 SKIPPED (123) *", "test_verbose_skip_reason.py::test_1 SKIPPED (123) *",
"test_verbose_skip_reason.py::test_2 XPASS (456) *", "test_verbose_skip_reason.py::test_2 XPASS (456) *",
"test_verbose_skip_reason.py::test_3 XFAIL (789) *", "test_verbose_skip_reason.py::test_3 XFAIL (789) *",
"test_verbose_skip_reason.py::test_4 XFAIL *",
] ]
) )