summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-10-13 19:53:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-10-13 19:53:13 (GMT)
commit24201d497cf23d399cceadad8058261c13ae536f (patch)
treee4ba7325e0e4e981f910f9e1707a2f5722e0107a /Lib
parent4e985673bf29677d243d68cf21884322df3319da (diff)
downloadcpython-24201d497cf23d399cceadad8058261c13ae536f.zip
cpython-24201d497cf23d399cceadad8058261c13ae536f.tar.gz
cpython-24201d497cf23d399cceadad8058261c13ae536f.tar.bz2
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
Diffstat (limited to 'Lib')
-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 5200af7..30c3b4a 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -74,6 +74,25 @@ class TestCase(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():