Skip to content

Commit 096bae6

Browse files
committed
unittest: add clarifying comment on unittest.SkipTest -> pytest.skip code
I was tempted to remove it, until I figured out why it was there.
1 parent addbd31 commit 096bae6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/_pytest/unittest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,17 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None:
343343
except AttributeError:
344344
pass
345345

346+
# Convert unittest.SkipTest to pytest.skip.
347+
# This is actually only needed for nose, which reuses unittest.SkipTest for
348+
# its own nose.SkipTest. For unittest TestCases, SkipTest is already
349+
# handled internally, and doesn't reach here.
346350
unittest = sys.modules.get("unittest")
347351
if (
348352
unittest
349353
and call.excinfo
350354
and isinstance(call.excinfo.value, unittest.SkipTest) # type: ignore[attr-defined]
351355
):
352356
excinfo = call.excinfo
353-
# Let's substitute the excinfo with a pytest.skip one.
354357
call2 = CallInfo[None].from_call(
355358
lambda: pytest.skip(str(excinfo.value)), call.when
356359
)

0 commit comments

Comments
 (0)