From: Serhiy Storchaka Date: Fri, 20 Nov 2015 16:33:02 +0000 (+0200) Subject: Issue #25665: Test pickling with all protocols in test_typing. X-Git-Tag: v3.5.1rc1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d9e92396f3603a45b5f2767f174d77f51a77536;p=thirdparty%2FPython%2Fcpython.git Issue #25665: Test pickling with all protocols in test_typing. --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 6ddaba94d54f..060119a134eb 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -602,11 +602,12 @@ class GenericTests(TestCase): c = C() c.foo = 42 c.bar = 'abc' - z = pickle.dumps(c) - x = pickle.loads(z) - self.assertEqual(x.foo, 42) - self.assertEqual(x.bar, 'abc') - self.assertEqual(x.__dict__, {'foo': 42, 'bar': 'abc'}) + 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') + self.assertEqual(x.__dict__, {'foo': 42, 'bar': 'abc'}) def test_errors(self): with self.assertRaises(TypeError): @@ -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) - jane2 = pickle.loads(z) - assert jane == jane2 + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + z = pickle.dumps(jane, proto) + jane2 = pickle.loads(z) + self.assertEqual(jane2, jane) class IOTests(TestCase):