(item: Item)
| 580 | |
| 581 | @hookimpl(wrapper=True) |
| 582 | def pytest_runtest_protocol(item: Item) -> Iterator[None]: |
| 583 | if _get_twisted_version() is TwistedVersion.Version24: |
| 584 | import twisted.python.failure as ut |
| 585 | |
| 586 | # Monkeypatch `Failure.__init__` to store the raw exception info. |
| 587 | original__init__ = ut.Failure.__init__ |
| 588 | |
| 589 | def store_raw_exception_info( |
| 590 | self, exc_value=None, exc_type=None, exc_tb=None, captureVars=None |
| 591 | ): # pragma: no cover |
| 592 | if exc_value is None: |
| 593 | raw_exc_info = sys.exc_info() |
| 594 | else: |
| 595 | if exc_type is None: |
| 596 | exc_type = type(exc_value) |
| 597 | if exc_tb is None: |
| 598 | exc_tb = sys.exc_info()[2] |
| 599 | raw_exc_info = (exc_type, exc_value, exc_tb) |
| 600 | setattr(self, TWISTED_RAW_EXCINFO_ATTR, tuple(raw_exc_info)) |
| 601 | try: |
| 602 | original__init__( |
| 603 | self, exc_value, exc_type, exc_tb, captureVars=captureVars |
| 604 | ) |
| 605 | except TypeError: # pragma: no cover |
| 606 | original__init__(self, exc_value, exc_type, exc_tb) |
| 607 | |
| 608 | with MonkeyPatch.context() as patcher: |
| 609 | patcher.setattr(ut.Failure, "__init__", store_raw_exception_info) |
| 610 | return (yield) |
| 611 | else: |
| 612 | return (yield) |
| 613 | |
| 614 | |
| 615 | def _handle_twisted_exc_info( |
nothing calls this directly
no test coverage detected