]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #4740: Use HIGHEST_PROTOCOL in pickle test.
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sat, 27 Dec 2008 04:19:48 +0000 (04:19 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sat, 27 Dec 2008 04:19:48 +0000 (04:19 +0000)
(There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2)

Lib/test/test_array.py
Lib/test/test_deque.py
Lib/test/test_set.py

index 2efbc7d6772f8aeb590b5b23e893834cd2e6672b..2c4c2fdc9f10fe849d2a3d34a023c8be1a97ef89 100755 (executable)
@@ -7,7 +7,7 @@ import unittest
 from test import test_support
 from weakref import proxy
 import array, cStringIO
-from cPickle import loads, dumps
+from cPickle import loads, dumps, HIGHEST_PROTOCOL
 
 class ArraySubclass(array.array):
     pass
@@ -97,7 +97,7 @@ class BaseTest(unittest.TestCase):
         self.assertEqual(a, b)
 
     def test_pickle(self):
-        for protocol in (0, 1, 2):
+        for protocol in range(HIGHEST_PROTOCOL + 1):
             a = array.array(self.typecode, self.example)
             b = loads(dumps(a, protocol))
             self.assertNotEqual(id(a), id(b))
@@ -112,7 +112,7 @@ class BaseTest(unittest.TestCase):
             self.assertEqual(type(a), type(b))
 
     def test_pickle_for_empty_array(self):
-        for protocol in (0, 1, 2):
+        for protocol in range(HIGHEST_PROTOCOL + 1):
             a = array.array(self.typecode)
             b = loads(dumps(a, protocol))
             self.assertNotEqual(id(a), id(b))
index 0b751d865cf59068c6ea7ff56504cbc89c593274..0f0d09847e60233d48be1a75a86c4a00cff61ab3 100644 (file)
@@ -373,7 +373,7 @@ class TestBasic(unittest.TestCase):
 
     def test_pickle(self):
         d = deque(xrange(200))
-        for i in (0, 1, 2):
+        for i in range(pickle.HIGHEST_PROTOCOL + 1):
             s = pickle.dumps(d, i)
             e = pickle.loads(s)
             self.assertNotEqual(id(d), id(e))
@@ -382,7 +382,7 @@ class TestBasic(unittest.TestCase):
 ##    def test_pickle_recursive(self):
 ##        d = deque('abc')
 ##        d.append(d)
-##        for i in (0, 1, 2):
+##        for i in range(pickle.HIGHEST_PROTOCOL + 1):
 ##            e = pickle.loads(pickle.dumps(d, i))
 ##            self.assertNotEqual(id(d), id(e))
 ##            self.assertEqual(id(e), id(e[-1]))
index 499406f3c266db6eeb4974ff49532960bd717517..d38a6759075fdc1c7f066c7fa2fd84b4e833885c 100644 (file)
@@ -221,7 +221,7 @@ class TestJointOps(unittest.TestCase):
         self.failIf(set('cbs').issuperset('a'))
 
     def test_pickling(self):
-        for i in (0, 1, 2):
+        for i in range(pickle.HIGHEST_PROTOCOL + 1):
             p = pickle.dumps(self.s, i)
             dup = pickle.loads(p)
             self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup))