From 37eab55ac9da6b6361f136a1da15bfcef12ed954 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 16 Jan 2022 07:33:28 +0300 Subject: bpo-46387: test all pickle protos in `test_field_descriptor` in `test_collections` (GH-30614) --- Lib/test/test_collections.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 48327bf..3a16045 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -677,14 +677,16 @@ class TestNamedTuple(unittest.TestCase): self.assertRaises(AttributeError, Point.x.__set__, p, 33) self.assertRaises(AttributeError, Point.x.__delete__, p) - class NewPoint(tuple): - x = pickle.loads(pickle.dumps(Point.x)) - y = pickle.loads(pickle.dumps(Point.y)) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(proto=proto): + class NewPoint(tuple): + x = pickle.loads(pickle.dumps(Point.x, proto)) + y = pickle.loads(pickle.dumps(Point.y, proto)) - np = NewPoint([1, 2]) + np = NewPoint([1, 2]) - self.assertEqual(np.x, 1) - self.assertEqual(np.y, 2) + self.assertEqual(np.x, 1) + self.assertEqual(np.y, 2) def test_new_builtins_issue_43102(self): obj = namedtuple('C', ()) -- cgit v0.12