()
| 60 | |
| 61 | |
| 62 | def unraisable_exception_runtest_hook() -> Generator[None, None, None]: |
| 63 | with catch_unraisable_exception() as cm: |
| 64 | yield |
| 65 | if cm.unraisable: |
| 66 | if cm.unraisable.err_msg is not None: |
| 67 | err_msg = cm.unraisable.err_msg |
| 68 | else: |
| 69 | err_msg = "Exception ignored in" |
| 70 | msg = f"{err_msg}: {cm.unraisable.object!r}\n\n" |
| 71 | msg += "".join( |
| 72 | traceback.format_exception( |
| 73 | cm.unraisable.exc_type, |
| 74 | cm.unraisable.exc_value, |
| 75 | cm.unraisable.exc_traceback, |
| 76 | ) |
| 77 | ) |
| 78 | warnings.warn(pytest.PytestUnraisableExceptionWarning(msg)) |
| 79 | |
| 80 | |
| 81 | @pytest.hookimpl(hookwrapper=True, tryfirst=True) |
no test coverage detected