summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-05-30 07:13:29 (GMT)
committerGeorg Brandl <georg@python.org>2006-05-30 07:13:29 (GMT)
commit05f97bffac5ae9ded29c5f845dff5edc99ff1620 (patch)
treea0eb1739480e8ae10b9d7f3032a93d1b94e807f9 /Lib
parentddba473e2639f4db6db51e66851a5c056ba0e18d (diff)
downloadcpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.zip
cpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.tar.gz
cpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.tar.bz2
Add a test case for exception pickling. args is never NULL.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_exceptions.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 076d84d..b4a766e 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -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)) ))