mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[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 5de7e3f973)
Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
6d21cc54ff
commit
c62c523e03
1 changed files with 11 additions and 7 deletions
|
|
@ -146,20 +146,24 @@ def setUp(self):
|
|||
@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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue