mirror of https://github.com/python/cpython
gh-100931: Test all `pickle` protocols in `test_slice` (#100932)
This commit is contained in:
parent
8dd2766d99
commit
8795ad1bd0
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue