[Python-checkins] r67931 - in python/branches/py3k/Lib/test: test_array.py test_deque.py test_set.py

hirokazu.yamamoto python-checkins at python.org
Sat Dec 27 05:21:44 CET 2008


Author: hirokazu.yamamoto
Date: Sat Dec 27 05:21:44 2008
New Revision: 67931

Log:
Issue #4740: Use HIGHEST_PROTOCOL in pickle test. This enables test for protocol 3
(== HIGHEST_PROTOCOL in 3.x)

Modified:
   python/branches/py3k/Lib/test/test_array.py
   python/branches/py3k/Lib/test/test_deque.py
   python/branches/py3k/Lib/test/test_set.py

Modified: python/branches/py3k/Lib/test/test_array.py
==============================================================================
--- python/branches/py3k/Lib/test/test_array.py	(original)
+++ python/branches/py3k/Lib/test/test_array.py	Sat Dec 27 05:21:44 2008
@@ -7,7 +7,7 @@
 from test import support
 from weakref import proxy
 import array, io, math
-from pickle import loads, dumps
+from pickle import loads, dumps, HIGHEST_PROTOCOL
 import operator
 
 class ArraySubclass(array.array):
@@ -98,7 +98,7 @@
         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))
@@ -113,7 +113,7 @@
             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))

Modified: python/branches/py3k/Lib/test/test_deque.py
==============================================================================
--- python/branches/py3k/Lib/test/test_deque.py	(original)
+++ python/branches/py3k/Lib/test/test_deque.py	Sat Dec 27 05:21:44 2008
@@ -375,7 +375,7 @@
 
     def test_pickle(self):
         d = deque(range(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))
@@ -384,7 +384,7 @@
 ##    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]))

Modified: python/branches/py3k/Lib/test/test_set.py
==============================================================================
--- python/branches/py3k/Lib/test/test_set.py	(original)
+++ python/branches/py3k/Lib/test/test_set.py	Sat Dec 27 05:21:44 2008
@@ -219,7 +219,7 @@
         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))


More information about the Python-checkins mailing list