Skip to content

Commit b8201c2

Browse files
committed
Merge pull request #8152 from bluetech/empty-skip
terminal: fix "(<Skipped instance>)" skip reason in test status line (cherry picked from commit 02e69e5)
1 parent 1f0c50b commit b8201c2

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

changelog/8152.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.

src/_pytest/outcomes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, msg: Optional[str] = None, pytrace: bool = True) -> None:
3838
self.pytrace = pytrace
3939

4040
def __repr__(self) -> str:
41-
if self.msg:
41+
if self.msg is not None:
4242
return self.msg
4343
return f"<{self.__class__.__name__} instance>"
4444

src/_pytest/terminal.py

+2
Original file line numberDiff line numberDiff line change
@@ -1400,4 +1400,6 @@ def _get_raw_skip_reason(report: TestReport) -> str:
14001400
_, _, reason = report.longrepr
14011401
if reason.startswith("Skipped: "):
14021402
reason = reason[len("Skipped: ") :]
1403+
elif reason == "Skipped":
1404+
reason = ""
14031405
return reason

testing/test_terminal.py

+26
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@ def test_3():
366366
@pytest.mark.xfail(reason="")
367367
def test_4():
368368
assert False
369+
370+
@pytest.mark.skip
371+
def test_5():
372+
pass
373+
374+
@pytest.mark.xfail
375+
def test_6():
376+
pass
377+
378+
def test_7():
379+
pytest.skip()
380+
381+
def test_8():
382+
pytest.skip("888 is great")
383+
384+
def test_9():
385+
pytest.xfail()
386+
387+
def test_10():
388+
pytest.xfail("It's 🕙 o'clock")
369389
"""
370390
)
371391
result = pytester.runpytest("-v")
@@ -375,6 +395,12 @@ def test_4():
375395
"test_verbose_skip_reason.py::test_2 XPASS (456) *",
376396
"test_verbose_skip_reason.py::test_3 XFAIL (789) *",
377397
"test_verbose_skip_reason.py::test_4 XFAIL *",
398+
"test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *",
399+
"test_verbose_skip_reason.py::test_6 XPASS *",
400+
"test_verbose_skip_reason.py::test_7 SKIPPED *",
401+
"test_verbose_skip_reason.py::test_8 SKIPPED (888 is great) *",
402+
"test_verbose_skip_reason.py::test_9 XFAIL *",
403+
"test_verbose_skip_reason.py::test_10 XFAIL (It's 🕙 o'clock) *",
378404
]
379405
)
380406

0 commit comments

Comments
 (0)