MCPcopy Index your code
hub / github.com/python/cpython / test_excepthook_thread_None

Method test_excepthook_thread_None

Lib/test/test_threading.py:2187–2205  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2185 @support.cpython_only
2186 @force_not_colorized
2187 def test_excepthook_thread_None(self):
2188 # threading.excepthook called with thread=None: log the thread
2189 # identifier in this case.
2190 with support.captured_output("stderr") as stderr:
2191 try:
2192 raise ValueError("bug")
2193 except Exception as exc:
2194 args = threading.ExceptHookArgs([*sys.exc_info(), None])
2195 try:
2196 threading.excepthook(args)
2197 finally:
2198 # Explicitly break a reference cycle
2199 args = None
2200
2201 stderr = stderr.getvalue().strip()
2202 self.assertIn(f'Exception in thread {threading.get_ident()}:\n', stderr)
2203 self.assertIn('Traceback (most recent call last):\n', stderr)
2204 self.assertIn(' raise ValueError("bug")', stderr)
2205 self.assertIn('ValueError: bug', stderr)
2206
2207 def test_system_exit(self):
2208 class ThreadExit(threading.Thread):

Callers

nothing calls this directly

Calls 4

excepthookMethod · 0.80
assertInMethod · 0.80
stripMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected