mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
Issue 10326: Fix regression to get test cases to pickle again.
This commit is contained in:
parent
5b0c22ced3
commit
67a3e8336f
2 changed files with 43 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
import difflib
|
||||
import pprint
|
||||
import pickle
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
@ -1104,6 +1105,20 @@ test case
|
|||
self.assertEqual(len(result.errors), 1)
|
||||
self.assertEqual(result.testsRun, 1)
|
||||
|
||||
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)
|
||||
|
||||
unpickled_test = pickle.loads(pickled_test)
|
||||
self.assertEqual(test, unpickled_test)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue