]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a test for slicing an exception.
authorBrett Cannon <bcannon@gmail.com>
Mon, 29 Jan 2007 04:41:44 +0000 (04:41 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 29 Jan 2007 04:41:44 +0000 (04:41 +0000)
Lib/test/test_exceptions.py
Misc/NEWS

index b0e872b777e1256a55a36e749c1a8cbf73b8e4ef..b99e24783585f0454365208a8492e3e4d5783877 100644 (file)
@@ -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
index aef42180a332c0d39c3db09f51c8db31d460c7e4..7dc2bc3574972594afcf45e1298b8ec40e2a0d35 100644 (file)
--- 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.