Skip to content

Commit c62c523

Browse files
[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 5de7e3f) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 6d21cc5 commit c62c523

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Lib/test/test_zoneinfo/test_zoneinfo_property.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,24 @@ def setUp(self):
146146
@add_key_examples
147147
def test_pickle_unpickle_cache(self, key):
148148
zi = self.klass(key)
149-
pkl_str = pickle.dumps(zi)
150-
zi_rt = pickle.loads(pkl_str)
149+
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
150+
with self.subTest(proto=proto):
151+
pkl_str = pickle.dumps(zi, proto)
152+
zi_rt = pickle.loads(pkl_str)
151153

152-
self.assertIs(zi, zi_rt)
154+
self.assertIs(zi, zi_rt)
153155

154156
@hypothesis.given(key=valid_keys())
155157
@add_key_examples
156158
def test_pickle_unpickle_no_cache(self, key):
157159
zi = self.klass.no_cache(key)
158-
pkl_str = pickle.dumps(zi)
159-
zi_rt = pickle.loads(pkl_str)
160+
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
161+
with self.subTest(proto=proto):
162+
pkl_str = pickle.dumps(zi, proto)
163+
zi_rt = pickle.loads(pkl_str)
160164

161-
self.assertIsNot(zi, zi_rt)
162-
self.assertEqual(str(zi), str(zi_rt))
165+
self.assertIsNot(zi, zi_rt)
166+
self.assertEqual(str(zi), str(zi_rt))
163167

164168
@hypothesis.given(key=valid_keys())
165169
@add_key_examples

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy