Skip to content

Commit 3302ff9

Browse files
committed
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.
1 parent 59bd0f6 commit 3302ff9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/_pytest/terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
554554
)
555555
reason = _get_raw_skip_reason(rep)
556556
reason_ = _format_trimmed(" ({})", reason, available_width)
557-
if reason_ is not None:
557+
if reason and reason_ is not None:
558558
self._tw.write(reason_)
559559
if self._show_progress_info:
560560
self._write_progress_information_filling_space()

testing/test_terminal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ def test_2():
362362
@pytest.mark.xfail(reason="789")
363363
def test_3():
364364
assert False
365+
366+
@pytest.mark.xfail(reason="")
367+
def test_4():
368+
assert False
365369
"""
366370
)
367371
result = pytester.runpytest("-v")
@@ -370,6 +374,7 @@ def test_3():
370374
"test_verbose_skip_reason.py::test_1 SKIPPED (123) *",
371375
"test_verbose_skip_reason.py::test_2 XPASS (456) *",
372376
"test_verbose_skip_reason.py::test_3 XFAIL (789) *",
377+
"test_verbose_skip_reason.py::test_4 XFAIL *",
373378
]
374379
)
375380

0 commit comments

Comments
 (0)