From 8795ad1bd0d6ee031543fcaf5a86a60b37950714 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 11 Jan 2023 12:43:45 +0300 Subject: gh-100931: Test all `pickle` protocols in `test_slice` (#100932) --- Lib/test/test_json/test_attrdict.py | 2 +- Lib/test/test_slice.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_json/test_attrdict.py b/Lib/test/test_json/test_attrdict.py index 48d14f4..143ea46 100644 --- a/Lib/test/test_json/test_attrdict.py +++ b/Lib/test/test_json/test_attrdict.py @@ -133,7 +133,7 @@ class TestAttrDict(PyTest): cached_module = sys.modules.get('json') sys.modules['json'] = self.json try: - for protocol in range(6): + for protocol in range(pickle.HIGHEST_PROTOCOL + 1): kepler_ad2 = pickle.loads(pickle.dumps(kepler_ad, protocol)) self.assertEqual(kepler_ad2, kepler_ad) self.assertEqual(type(kepler_ad2), AttrDict) diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index 4ae4142..c4bc8c8 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -235,8 +235,10 @@ class SliceTest(unittest.TestCase): self.assertEqual(tmp, [(slice(1, 2), 42)]) def test_pickle(self): + import pickle + s = slice(10, 20, 3) - for protocol in (0,1,2): + for protocol in range(pickle.HIGHEST_PROTOCOL + 1): t = loads(dumps(s, protocol)) self.assertEqual(s, t) self.assertEqual(s.indices(15), t.indices(15)) -- cgit v0.12