diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-13 19:54:15 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-10-13 19:54:15 (GMT) |
commit | 6039db8de30b5c20ba864cc4127fbfabf6fc0641 (patch) | |
tree | 6820fd9758156c17a71c07b906e9c45d5a0c9599 /Lib/test/test_atexit.py | |
parent | fbc3c3c2bed34350e0dde4771805c51b80f2e410 (diff) | |
parent | 24201d497cf23d399cceadad8058261c13ae536f (diff) | |
download | cpython-6039db8de30b5c20ba864cc4127fbfabf6fc0641.zip cpython-6039db8de30b5c20ba864cc4127fbfabf6fc0641.tar.gz cpython-6039db8de30b5c20ba864cc4127fbfabf6fc0641.tar.bz2 |
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 3e25236..b641015 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(): |