MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_original_excepthook

Method test_original_excepthook

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

Source from the content-addressed store, hash-verified

2056 self.assertEqual(err_str, 'threading_hook failed')
2057
2058 def test_original_excepthook(self):
2059 def run_thread():
2060 with support.captured_output("stderr") as output:
2061 thread = ThreadRunFail(name="excepthook thread")
2062 thread.start()
2063 thread.join()
2064 return output.getvalue()
2065
2066 def threading_hook(args):
2067 print("Running a thread failed", file=sys.stderr)
2068
2069 default_output = run_thread()
2070 with support.swap_attr(threading, 'excepthook', threading_hook):
2071 custom_hook_output = run_thread()
2072 threading.excepthook = threading.__excepthook__
2073 recovered_output = run_thread()
2074
2075 self.assertEqual(default_output, recovered_output)
2076 self.assertNotEqual(default_output, custom_hook_output)
2077 self.assertEqual(custom_hook_output, "Running a thread failed\n")
2078
2079
2080class TimerTests(BaseTestCase):

Callers

nothing calls this directly

Calls 3

run_threadFunction · 0.85
assertNotEqualMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected