FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #4740: Use HIGHEST_PROTOCOL in pickle test. · java66liu/python@75a8b72 · GitHub

forked from glix/python

Commit 75a8b72

Browse files
hirokazu.yamamoto
committed
Issue #4740: Use HIGHEST_PROTOCOL in pickle test.
(There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2) git-svn-id: http://svn.python.org/projects/python/trunk@67930 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a5df2e2 commit 75a8b72

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎Lib/test/test_array.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from test import test_support
88
from weakref import proxy
99
import array, cStringIO
10-
from cPickle import loads, dumps
10+
from cPickle import loads, dumps, HIGHEST_PROTOCOL
1111

1212
class ArraySubclass(array.array):
1313
pass
@@ -97,7 +97,7 @@ def test_deepcopy(self):
9797
self.assertEqual(a, b)
9898

9999
def test_pickle(self):
100-
for protocol in (0, 1, 2):
100+
for protocol in range(HIGHEST_PROTOCOL + 1):
101101
a = array.array(self.typecode, self.example)
102102
b = loads(dumps(a, protocol))
103103
self.assertNotEqual(id(a), id(b))
@@ -112,7 +112,7 @@ def test_pickle(self):
112112
self.assertEqual(type(a), type(b))
113113

114114
def test_pickle_for_empty_array(self):
115-
for protocol in (0, 1, 2):
115+
for protocol in range(HIGHEST_PROTOCOL + 1):
116116
a = array.array(self.typecode)
117117
b = loads(dumps(a, protocol))
118118
self.assertNotEqual(id(a), id(b))

‎Lib/test/test_deque.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def test_roundtrip_iter_init(self):
373373

374374
def test_pickle(self):
375375
d = deque(xrange(200))
376-
for i in (0, 1, 2):
376+
for i in range(pickle.HIGHEST_PROTOCOL + 1):
377377
s = pickle.dumps(d, i)
378378
e = pickle.loads(s)
379379
self.assertNotEqual(id(d), id(e))
@@ -382,7 +382,7 @@ def test_pickle(self):
382382
## def test_pickle_recursive(self):
383383
## d = deque('abc')
384384
## d.append(d)
385-
## for i in (0, 1, 2):
385+
## for i in range(pickle.HIGHEST_PROTOCOL + 1):
386386
## e = pickle.loads(pickle.dumps(d, i))
387387
## self.assertNotEqual(id(d), id(e))
388388
## self.assertEqual(id(e), id(e[-1]))

‎Lib/test/test_set.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_sub_and_super(self):
221221
self.failIf(set('cbs').issuperset('a'))
222222

223223
def test_pickling(self):
224-
for i in (0, 1, 2):
224+
for i in range(pickle.HIGHEST_PROTOCOL + 1):
225225
p = pickle.dumps(self.s, i)
226226
dup = pickle.loads(p)
227227
self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup))

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL