gh-100931: Test all `pickle` protocols in `test_slice` (#100932)

This commit is contained in:
Nikita Sobolev 2023-01-11 12:43:45 +03:00 committed by GitHub
parent 8dd2766d99
commit 8795ad1bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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))