From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 5 Jul 2025 06:39:48 +0000 (+0200) Subject: [3.14] gh-136297: Test all `pickle` protocols in `test_zoneinfo_property.py` (GH... X-Git-Tag: v3.14.0b4~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c62c523e034ddef262e90c16c6e2fef69ff7d469;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-136297: Test all `pickle` protocols in `test_zoneinfo_property.py` (GH-136298) (#136311) gh-136297: Test all `pickle` protocols in `test_zoneinfo_property.py` (GH-136298) (cherry picked from commit 5de7e3f9739b01ad180fffb242ac57cea930e74d) Co-authored-by: sobolevn --- diff --git a/Lib/test/test_zoneinfo/test_zoneinfo_property.py b/Lib/test/test_zoneinfo/test_zoneinfo_property.py index feaa77f3e7f0..294c7e9b27a8 100644 --- a/Lib/test/test_zoneinfo/test_zoneinfo_property.py +++ b/Lib/test/test_zoneinfo/test_zoneinfo_property.py @@ -146,20 +146,24 @@ class ZoneInfoPickleTest(ZoneInfoTestBase): @add_key_examples def test_pickle_unpickle_cache(self, key): zi = self.klass(key) - pkl_str = pickle.dumps(zi) - zi_rt = pickle.loads(pkl_str) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(proto=proto): + pkl_str = pickle.dumps(zi, proto) + zi_rt = pickle.loads(pkl_str) - self.assertIs(zi, zi_rt) + self.assertIs(zi, zi_rt) @hypothesis.given(key=valid_keys()) @add_key_examples def test_pickle_unpickle_no_cache(self, key): zi = self.klass.no_cache(key) - pkl_str = pickle.dumps(zi) - zi_rt = pickle.loads(pkl_str) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(proto=proto): + pkl_str = pickle.dumps(zi, proto) + zi_rt = pickle.loads(pkl_str) - self.assertIsNot(zi, zi_rt) - self.assertEqual(str(zi), str(zi_rt)) + self.assertIsNot(zi, zi_rt) + self.assertEqual(str(zi), str(zi_rt)) @hypothesis.given(key=valid_keys()) @add_key_examples