diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-11-20 15:34:26 +0000 |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-11-20 15:34:26 +0000 |
commit | 8ca6d9884bcbdd05fe270e75e10f51af614e22a2 (patch) | |
tree | d6a9280c42e73fa1f344b415aacc759df3bae957 /Lib/unittest/test/test_case.py | |
parent | e5db2636f3fedd772e55ce55e4cf820475f29fe3 (diff) | |
download | cpython-git-8ca6d9884bcbdd05fe270e75e10f51af614e22a2.tar.gz |
Issue 10326: TestCase instances can now be pickled (they store names of instance methods instead of references to the instance methods themselves).
Diffstat (limited to 'Lib/unittest/test/test_case.py')
-rw-r--r-- | Lib/unittest/test/test_case.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index 1bd839f27e..444b58be06 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -1,5 +1,6 @@ import difflib import pprint +import pickle import re import sys import warnings @@ -1095,3 +1096,14 @@ test case # This shouldn't blow up deepcopy(test) + + def testPickle(self): + # Issue 10326 + + # Can't use TestCase classes defined in Test class as + # pickle does not work with inner classes + test = unittest.TestCase('run') + for protocol in range(pickle.HIGHEST_PROTOCOL + 1): + + # blew up prior to fix + pickled_test = pickle.dumps(test, protocol=protocol) |