From: Brett Cannon Date: Mon, 29 Jan 2007 04:41:44 +0000 (+0000) Subject: Add a test for slicing an exception. X-Git-Tag: v2.6a1~2222 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e05e6b0032a58fe5e4ff3b2b9b64c6e37da4defa;p=thirdparty%2FPython%2Fcpython.git Add a test for slicing an exception. --- diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index b0e872b777e1..b99e24783585 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -296,6 +296,13 @@ class ExceptionTests(unittest.TestCase): 'pickled "%r", attribute "%s' % (e, checkArgName)) + def testSlicing(self): + # Test that you can slice an exception directly instead of requiring + # going through the 'args' attribute. + args = (1, 2, 3) + exc = BaseException(*args) + self.failUnlessEqual(exc[:], args) + def testKeywordArgs(self): # test that builtin exception don't take keyword args, # but user-defined subclasses can if they want diff --git a/Misc/NEWS b/Misc/NEWS index aef42180a332..7dc2bc357497 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -403,6 +403,8 @@ Extension Modules Tests ----- +- Added a test for slicing of an exception. + - Added test.test_support.EnvironmentVarGuard. It's a class that provides a context manager so that one can temporarily set or unset environment variables.