Make sure that we are cancelling any scheduled traceback dumping due to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any other interactive exception (pytest-dev/pytest-faulthandler#14).
(monkeypatch, hook_name)
| 109 | |
| 110 | @pytest.mark.parametrize("hook_name", ["pytest_enter_pdb", "pytest_exception_interact"]) |
| 111 | def test_cancel_timeout_on_hook(monkeypatch, hook_name) -> None: |
| 112 | """Make sure that we are cancelling any scheduled traceback dumping due |
| 113 | to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any |
| 114 | other interactive exception (pytest-dev/pytest-faulthandler#14).""" |
| 115 | import faulthandler |
| 116 | from _pytest import faulthandler as faulthandler_plugin |
| 117 | |
| 118 | called = [] |
| 119 | |
| 120 | monkeypatch.setattr( |
| 121 | faulthandler, "cancel_dump_traceback_later", lambda: called.append(1) |
| 122 | ) |
| 123 | |
| 124 | # call our hook explicitly, we can trust that pytest will call the hook |
| 125 | # for us at the appropriate moment |
| 126 | hook_func = getattr(faulthandler_plugin, hook_name) |
| 127 | hook_func() |
| 128 | assert called == [1] |
| 129 | |
| 130 | |
| 131 | def test_already_initialized_crash(pytester: Pytester) -> None: |