MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_cancel_timeout_on_hook

Function test_cancel_timeout_on_hook

testing/test_faulthandler.py:111–128  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

109
110@pytest.mark.parametrize("hook_name", ["pytest_enter_pdb", "pytest_exception_interact"])
111def 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
131def test_already_initialized_crash(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 2

setattrMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected