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

Function thread_exception_runtest_hook

src/_pytest/threadexception.py:60–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58
59
60def thread_exception_runtest_hook() -> Generator[None, None, None]:
61 with catch_threading_exception() as cm:
62 yield
63 if cm.args:
64 thread_name = "<unknown>" if cm.args.thread is None else cm.args.thread.name
65 msg = f"Exception in thread {thread_name}\n\n"
66 msg += "".join(
67 traceback.format_exception(
68 cm.args.exc_type,
69 cm.args.exc_value,
70 cm.args.exc_traceback,
71 )
72 )
73 warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
74
75
76@pytest.hookimpl(hookwrapper=True, trylast=True)

Callers 3

pytest_runtest_setupFunction · 0.85
pytest_runtest_callFunction · 0.85
pytest_runtest_teardownFunction · 0.85

Calls 2

warnMethod · 0.45

Tested by

no test coverage detected