Skip to content

Commit

Permalink
Merge pull request #8163 from bluetech/backport-8152
Browse files Browse the repository at this point in the history
[6.2.x] terminal: fix "(<Skipped instance>)" skip reason in test status line
  • Loading branch information
nicoddemus authored Dec 17, 2020
2 parents 1f0c50b + b8201c2 commit f7d1ab8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/8152.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.
2 changes: 1 addition & 1 deletion src/_pytest/outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, msg: Optional[str] = None, pytrace: bool = True) -> None:
self.pytrace = pytrace

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

Expand Down
2 changes: 2 additions & 0 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,4 +1400,6 @@ def _get_raw_skip_reason(report: TestReport) -> str:
_, _, reason = report.longrepr
if reason.startswith("Skipped: "):
reason = reason[len("Skipped: ") :]
elif reason == "Skipped":
reason = ""
return reason
26 changes: 26 additions & 0 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,26 @@ def test_3():
@pytest.mark.xfail(reason="")
def test_4():
assert False
@pytest.mark.skip
def test_5():
pass
@pytest.mark.xfail
def test_6():
pass
def test_7():
pytest.skip()
def test_8():
pytest.skip("888 is great")
def test_9():
pytest.xfail()
def test_10():
pytest.xfail("It's 🕙 o'clock")
"""
)
result = pytester.runpytest("-v")
Expand All @@ -375,6 +395,12 @@ def test_4():
"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 *",
"test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *",
"test_verbose_skip_reason.py::test_6 XPASS *",
"test_verbose_skip_reason.py::test_7 SKIPPED *",
"test_verbose_skip_reason.py::test_8 SKIPPED (888 is great) *",
"test_verbose_skip_reason.py::test_9 XFAIL *",
"test_verbose_skip_reason.py::test_10 XFAIL (It's 🕙 o'clock) *",
]
)

Expand Down

0 comments on commit f7d1ab8

Please sign in to comment.