diff options
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 076d84d80e..b4a766e89b 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)) )) |