]> 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:43:13 +0000 (10:43 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Wed, 19 Feb 2014 16:43:13 +0000 (10:43 -0600)
exception raised by sys.exit is None when no code is given.

As suggested by Serhiy Storchaka.

Lib/test/test_sys.py

index 7c7e0af8490698a6f1424f5c65d79c4c4632e8bf..745e4ada8c00d51aec2b1ee846d9254f94aab7e1 100644 (file)
@@ -119,6 +119,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'')