| 332 | |
| 333 | @hookimpl(tryfirst=True) |
| 334 | def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None: |
| 335 | if isinstance(item, TestCaseFunction): |
| 336 | if item._excinfo: |
| 337 | call.excinfo = item._excinfo.pop(0) |
| 338 | try: |
| 339 | del call.result |
| 340 | except AttributeError: |
| 341 | pass |
| 342 | |
| 343 | # Convert unittest.SkipTest to pytest.skip. |
| 344 | # This is actually only needed for nose, which reuses unittest.SkipTest for |
| 345 | # its own nose.SkipTest. For unittest TestCases, SkipTest is already |
| 346 | # handled internally, and doesn't reach here. |
| 347 | unittest = sys.modules.get("unittest") |
| 348 | if ( |
| 349 | unittest |
| 350 | and call.excinfo |
| 351 | and isinstance(call.excinfo.value, unittest.SkipTest) # type: ignore[attr-defined] |
| 352 | ): |
| 353 | excinfo = call.excinfo |
| 354 | call2 = CallInfo[None].from_call( |
| 355 | lambda: pytest.skip(str(excinfo.value)), call.when |
| 356 | ) |
| 357 | call.excinfo = call2.excinfo |
| 358 | |
| 359 | |
| 360 | # Twisted trial support. |