| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a5df2e2 commit 75a8b72
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | from test import test_support | |
| 8 | 8 | from weakref import proxy | |
| 9 | 9 | import array, cStringIO | |
| 10 | - from cPickle import loads, dumps | ||
| 10 | + from cPickle import loads, dumps, HIGHEST_PROTOCOL | ||
| 11 | 11 | ||
| 12 | 12 | class ArraySubclass(array.array): | |
| 13 | 13 | pass | |
@@ -97,7 +97,7 @@ def test_deepcopy(self): | |||
| 97 | 97 | self.assertEqual(a, b) | |
| 98 | 98 | ||
| 99 | 99 | def test_pickle(self): | |
| 100 | - for protocol in (0, 1, 2): | ||
| 100 | + for protocol in range(HIGHEST_PROTOCOL + 1): | ||
| 101 | 101 | a = array.array(self.typecode, self.example) | |
| 102 | 102 | b = loads(dumps(a, protocol)) | |
| 103 | 103 | self.assertNotEqual(id(a), id(b)) | |
@@ -112,7 +112,7 @@ def test_pickle(self): | |||
| 112 | 112 | self.assertEqual(type(a), type(b)) | |
| 113 | 113 | ||
| 114 | 114 | def test_pickle_for_empty_array(self): | |
| 115 | - for protocol in (0, 1, 2): | ||
| 115 | + for protocol in range(HIGHEST_PROTOCOL + 1): | ||
| 116 | 116 | a = array.array(self.typecode) | |
| 117 | 117 | b = loads(dumps(a, protocol)) | |
| 118 | 118 | self.assertNotEqual(id(a), id(b)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -373,7 +373,7 @@ def test_roundtrip_iter_init(self): | |||
| 373 | 373 | ||
| 374 | 374 | def test_pickle(self): | |
| 375 | 375 | d = deque(xrange(200)) | |
| 376 | - for i in (0, 1, 2): | ||
| 376 | + for i in range(pickle.HIGHEST_PROTOCOL + 1): | ||
| 377 | 377 | s = pickle.dumps(d, i) | |
| 378 | 378 | e = pickle.loads(s) | |
| 379 | 379 | self.assertNotEqual(id(d), id(e)) | |
@@ -382,7 +382,7 @@ def test_pickle(self): | |||
| 382 | 382 | ## def test_pickle_recursive(self): | |
| 383 | 383 | ## d = deque('abc') | |
| 384 | 384 | ## d.append(d) | |
| 385 | - ## for i in (0, 1, 2): | ||
| 385 | + ## for i in range(pickle.HIGHEST_PROTOCOL + 1): | ||
| 386 | 386 | ## e = pickle.loads(pickle.dumps(d, i)) | |
| 387 | 387 | ## self.assertNotEqual(id(d), id(e)) | |
| 388 | 388 | ## self.assertEqual(id(e), id(e[-1])) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -221,7 +221,7 @@ def test_sub_and_super(self): | |||
| 221 | 221 | self.failIf(set('cbs').issuperset('a')) | |
| 222 | 222 | ||
| 223 | 223 | def test_pickling(self): | |
| 224 | - for i in (0, 1, 2): | ||
| 224 | + for i in range(pickle.HIGHEST_PROTOCOL + 1): | ||
| 225 | 225 | p = pickle.dumps(self.s, i) | |
| 226 | 226 | dup = pickle.loads(p) | |
| 227 | 227 | self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments