]> granicus.if.org Git - python/commitdiff
Issue #20510: Confirm that the code attribute of the SystemExit
authorZachary Ware <zachary.ware@gmail.com>
Wed, 19 Feb 2014 16:44:47 +0000 (10:44 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Wed, 19 Feb 2014 16:44:47 +0000 (10:44 -0600)
exception raised by sys.exit is None when no code is given.

As suggested by Serhiy Storchaka.

Lib/test/test_sys.py

index 491ae9ce3ef55bd48fe5d40c869ee9c3b9c812de..f768e9b7c3abc85f3ddc67d7c6ce7e3a38d737f8 100644 (file)
@@ -91,6 +91,10 @@ class SysModuleTest(unittest.TestCase):
         self.assertRaises(TypeError, sys.exit, 42, 42)
 
         # call without argument
+        with self.assertRaises(SystemExit) as cm:
+            sys.exit()
+        self.assertIsNone(cm.exception.code)
+
         rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()')
         self.assertEqual(rc, 0)
         self.assertEqual(out, b'')