mirror of
https://github.com/python/cpython.git
synced 2025-09-16 21:56:14 +00:00
Add a test case for exception pickling. args is never NULL.
This commit is contained in:
parent
ddba473e26
commit
05f97bffac
2 changed files with 21 additions and 11 deletions
|
@ -270,6 +270,8 @@ try:
|
|||
'winerror' : 1 }))
|
||||
except NameError: pass
|
||||
|
||||
import pickle, random
|
||||
|
||||
for args in exceptionList:
|
||||
expected = args[-1]
|
||||
try:
|
||||
|
@ -283,3 +285,14 @@ for args in exceptionList:
|
|||
( repr(e), checkArgName,
|
||||
repr(expected[checkArgName]),
|
||||
repr(getattr(e, checkArgName)) ))
|
||||
|
||||
# test for pickling support
|
||||
new = pickle.loads(pickle.dumps(e, random.randint(0, 2)))
|
||||
for checkArgName in expected.keys():
|
||||
if repr(getattr(e, checkArgName)) != repr(expected[checkArgName]):
|
||||
raise TestFailed('Checking unpickled exception arguments, '
|
||||
'exception '
|
||||
'"%s", attribute "%s" expected %s got %s.' %
|
||||
( repr(e), checkArgName,
|
||||
repr(expected[checkArgName]),
|
||||
repr(getattr(e, checkArgName)) ))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue