(self)
| 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 | |
| 2080 | class TimerTests(BaseTestCase): |
nothing calls this directly
no test coverage detected