mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Add a test for slicing an exception.
This commit is contained in:
parent
af3d627022
commit
e05e6b0032
2 changed files with 9 additions and 0 deletions
|
|
@ -296,6 +296,13 @@ class ExceptionTests(unittest.TestCase):
|
||||||
'pickled "%r", attribute "%s' %
|
'pickled "%r", attribute "%s' %
|
||||||
(e, checkArgName))
|
(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):
|
def testKeywordArgs(self):
|
||||||
# test that builtin exception don't take keyword args,
|
# test that builtin exception don't take keyword args,
|
||||||
# but user-defined subclasses can if they want
|
# but user-defined subclasses can if they want
|
||||||
|
|
|
||||||
|
|
@ -403,6 +403,8 @@ Extension Modules
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Added a test for slicing of an exception.
|
||||||
|
|
||||||
- Added test.test_support.EnvironmentVarGuard. It's a class that provides a
|
- Added test.test_support.EnvironmentVarGuard. It's a class that provides a
|
||||||
context manager so that one can temporarily set or unset environment
|
context manager so that one can temporarily set or unset environment
|
||||||
variables.
|
variables.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue