diff options
author | Ran Benita <ran@unusedvar.com> | 2021-01-14 17:05:01 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2021-01-14 17:06:14 +0200 |
commit | 096bae6c68840c19bdc97cdfdf99b96dbcb2c427 (patch) | |
tree | e7efd2a082dc5905ad361db26ef93ea4e78d64cd /src/_pytest/unittest.py | |
parent | addbd3161e37edffebb2c0f6527da49b0515d1a1 (diff) | |
download | pytest-096bae6c68840c19bdc97cdfdf99b96dbcb2c427.tar.gz |
unittest: add clarifying comment on unittest.SkipTest -> pytest.skip code
I was tempted to remove it, until I figured out why it was there.
Diffstat (limited to 'src/_pytest/unittest.py')
-rw-r--r-- | src/_pytest/unittest.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index cc616578b..6a90188ca 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -343,6 +343,10 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None: except AttributeError: pass + # Convert unittest.SkipTest to pytest.skip. + # This is actually only needed for nose, which reuses unittest.SkipTest for + # its own nose.SkipTest. For unittest TestCases, SkipTest is already + # handled internally, and doesn't reach here. unittest = sys.modules.get("unittest") if ( unittest @@ -350,7 +354,6 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None: and isinstance(call.excinfo.value, unittest.SkipTest) # type: ignore[attr-defined] ): excinfo = call.excinfo - # Let's substitute the excinfo with a pytest.skip one. call2 = CallInfo[None].from_call( lambda: pytest.skip(str(excinfo.value)), call.when ) |