summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2005-02-15 15:26:11 (GMT)
committerMichael W. Hudson <mwh@python.net>2005-02-15 15:26:11 (GMT)
commitf0588583475fed46adac06dce59d82f7f34ca966 (patch)
treee72806a86730e1b4e4e59791881d2a736cef2b9f /Lib/test/test_sys.py
parenta1fb4c891f84989345b0967236954da1c6a94f34 (diff)
downloadcpython-f0588583475fed46adac06dce59d82f7f34ca966.zip
cpython-f0588583475fed46adac06dce59d82f7f34ca966.tar.gz
cpython-f0588583475fed46adac06dce59d82f7f34ca966.tar.bz2
Test that SystemExits are handled properly by the exit machinery. I
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).
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 48336b4..9aafbbc 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -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)