]> granicus.if.org Git - python/commitdiff
Test that SystemExits are handled properly by the exit machinery. I
authorMichael W. Hudson <mwh@python.net>
Tue, 15 Feb 2005 15:26:11 +0000 (15:26 +0000)
committerMichael W. Hudson <mwh@python.net>
Tue, 15 Feb 2005 15:26:11 +0000 (15:26 +0000)
broke the "raise SystemExit(46)" case when doing new-style exceptions,
but I'd much rather have found out here than in test_tempfile (growl).

Lib/test/test_sys.py

index 48336b45a722427c9ce6c58dea44b467b2795147..9aafbbc4baf1ae2b328ad0b6d5935df7854a208a 100644 (file)
@@ -161,6 +161,18 @@ class SysModuleTest(unittest.TestCase):
         else:
             self.fail("no exception")
 
+        # test that the exit machinery handles SystemExits properly
+        import subprocess
+        # both unnormalized...
+        rc = subprocess.call([sys.executable, "-c",
+                              "raise SystemExit, 46"])
+        self.assertEqual(rc, 46)
+        # ... and normalized
+        rc = subprocess.call([sys.executable, "-c",
+                              "raise SystemExit(47)"])
+        self.assertEqual(rc, 47)
+        
+            
     def test_getdefaultencoding(self):
         if test.test_support.have_unicode:
             self.assertRaises(TypeError, sys.getdefaultencoding, 42)