diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-13 21:54:15 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-13 21:54:15 +0200 |
commit | 52c962ffacbf51812028f991939c36918062e94f (patch) | |
tree | a0b085b5adf9a7c7368fe201695e9d06fc6d6d08 /Lib/test/test_atexit.py | |
parent | 51ec371f8d16c26f1c4792c79aefc8497dabe113 (diff) | |
parent | a5b3af7156594cc0a7964ac808f7807970912c8e (diff) | |
download | cpython-52c962ffacbf51812028f991939c36918062e94f.tar.gz |
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
Diffstat (limited to 'Lib/test/test_atexit.py')
-rw-r--r-- | Lib/test/test_atexit.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index 3e252367eb..b641015b70 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -77,6 +77,25 @@ class GeneralTest(unittest.TestCase): self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs) self.assertIn("ZeroDivisionError", self.stream.getvalue()) + def test_print_tracebacks(self): + # Issue #18776: the tracebacks should be printed when errors occur. + def f(): + 1/0 # one + def g(): + 1/0 # two + def h(): + 1/0 # three + atexit.register(f) + atexit.register(g) + atexit.register(h) + + self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs) + stderr = self.stream.getvalue() + self.assertEqual(stderr.count("ZeroDivisionError"), 3) + self.assertIn("# one", stderr) + self.assertIn("# two", stderr) + self.assertIn("# three", stderr) + def test_stress(self): a = [0] def inc(): |