diff options
Diffstat (limited to 'Lib/test/test_thread.py')
-rw-r--r-- | Lib/test/test_thread.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index f4eb830cf6..f946f7bc83 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -154,6 +154,24 @@ class ThreadRunningTests(BasicThreadTest): started.acquire() self.assertIn("Traceback", stderr.getvalue()) + def test_unraisable_exception(self): + def task(): + started.release() + raise ValueError("task failed") + + started = thread.allocate_lock() + with support.catch_unraisable_exception() as cm: + with support.wait_threads_exit(): + started.acquire() + thread.start_new_thread(task, ()) + started.acquire() + + self.assertEqual(str(cm.unraisable.exc_value), "task failed") + self.assertIs(cm.unraisable.object, task) + self.assertEqual(cm.unraisable.err_msg, + "Exception ignored in thread started by") + self.assertIsNotNone(cm.unraisable.exc_traceback) + class Barrier: def __init__(self, num_threads): |