summaryrefslogtreecommitdiff
path: root/Lib/test/test_atexit.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-10-13 21:54:15 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-10-13 21:54:15 +0200
commit52c962ffacbf51812028f991939c36918062e94f (patch)
treea0b085b5adf9a7c7368fe201695e9d06fc6d6d08 /Lib/test/test_atexit.py
parent51ec371f8d16c26f1c4792c79aefc8497dabe113 (diff)
parenta5b3af7156594cc0a7964ac808f7807970912c8e (diff)
downloadcpython-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.py19
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():