Issue #25665: Test pickling with all protocols in test_typing.

This commit is contained in:
Serhiy Storchaka 2015-11-20 18:33:33 +02:00
commit 9e788af7cc
1 changed files with 10 additions and 8 deletions

View File

@ -602,7 +602,8 @@ class GenericTests(TestCase):
c = C()
c.foo = 42
c.bar = 'abc'
z = pickle.dumps(c)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
z = pickle.dumps(c, proto)
x = pickle.loads(z)
self.assertEqual(x.foo, 42)
self.assertEqual(x.bar, 'abc')
@ -1167,9 +1168,10 @@ class NamedTupleTests(TestCase):
global Emp # pickle wants to reference the class by name
Emp = NamedTuple('Emp', [('name', str), ('id', int)])
jane = Emp('jane', 37)
z = pickle.dumps(jane)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
z = pickle.dumps(jane, proto)
jane2 = pickle.loads(z)
assert jane == jane2
self.assertEqual(jane2, jane)
class IOTests(TestCase):