8000 gh-100931: Test all `pickle` protocols in `test_slice` (#100932) · python/cpython@8795ad1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8795ad1

Browse files
authored
gh-100931: Test all pickle protocols in test_slice (#100932)
1 parent 8dd2766 commit 8795ad1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/test/test_json/test_attrdict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_pickle(self):
133133
cached_module = sys.modules.get('json')
134134
sys.modules['json'] = self.json
135135
try:
136-
for protocol in range(6):
136+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
137137
kepler_ad2 = pickle.loads(pickle.dumps(kepler_ad, protocol))
138138
self.assertEqual(kepler_ad2, kepler_ad)
139139
self.assertEqual(type(kepler_ad2), AttrDict)

Lib/test/test_slice.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ def __setitem__(self, i, k):
235235
self.assertEqual(tmp, [(slice(1, 2), 42)])
236236

237237
def test_pickle(self):
238+
import pickle
239+
238240
s = slice(10, 20, 3)
239-
for protocol in (0,1,2):
241+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
240242
t = loads(dumps(s, protocol))
241243
self.assertEqual(s, t)
242244
self.assertEqual(s.indices(15), t.indices(15))

0 commit comments

Comments
 (0)
0