From 3302ff994959964c3ec2ab35ec1fe98c038684c0 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 12 Dec 2020 22:09:00 +0200 Subject: [PATCH] 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. --- src/_pytest/terminal.py | 2 +- testing/test_terminal.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 2e68e257548..0e0ed70e5be 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -554,7 +554,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None: ) reason = _get_raw_skip_reason(rep) reason_ = _format_trimmed(" ({})", reason, available_width) - if reason_ is not None: + if reason and reason_ is not None: self._tw.write(reason_) if self._show_progress_info: self._write_progress_information_filling_space() diff --git a/testing/test_terminal.py b/testing/test_terminal.py index fdd4301f94f..7ad5849d4b9 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -362,6 +362,10 @@ def test_2(): @pytest.mark.xfail(reason="789") def test_3(): assert False + + @pytest.mark.xfail(reason="") + def test_4(): + assert False """ ) result = pytester.runpytest("-v") @@ -370,6 +374,7 @@ def test_3(): "test_verbose_skip_reason.py::test_1 SKIPPED (123) *", "test_verbose_skip_reason.py::test_2 XPASS (456) *", "test_verbose_skip_reason.py::test_3 XFAIL (789) *", + "test_verbose_skip_reason.py::test_4 XFAIL *", ] )