gh-100931: Test all `pickle` protocols in `test_slice`
diff --git a/Lib/test/test_json/test_attrdict.py b/Lib/test/test_json/test_attrdict.py
index 48d14f4db93c12..143ea462d310aa 100644
--- a/Lib/test/test_json/test_attrdict.py
+++ b/Lib/test/test_json/test_attrdict.py
@@ -133,7 +133,7 @@ def test_pickle(self):
         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 4ae4142c60c8a8..c4bc8c82023d74 100644
--- a/Lib/test/test_slice.py
+++ b/Lib/test/test_slice.py
@@ -235,8 +235,10 @@ def __setitem__(self, i, k):
         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))



<!-- gh-issue-number: gh-100931 -->
* Issue: gh-100931
<!-- /gh-issue-number -->
