Merge pull request #8128 from bluetech/skip-reason-empty

terminal: when the skip/xfail is empty, don't show it as "()"
This commit is contained in:
Ran Benita 2020-12-12 22:18:06 +02:00 committed by GitHub
commit b478275777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 *",
] ]
) )