def test_cancel_timeout_on_hook(monkeypatch, hook_name) -> None:
    """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)."""
    import faulthandler

    from _pytest import faulthandler as faulthandler_plugin

    called = []

    monkeypatch.setattr(
        faulthandler, "cancel_dump_traceback_later", lambda: called.append(1)
    )

    # call our hook explicitly, we can trust that pytest will call the hook
    # for us at the appropriate moment
    hook_func = getattr(faulthandler_plugin, hook_name)
    hook_func()
    assert called == [1]
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).
testing/test_faulthandler.py