Commit 834809a8 authored by Hirokazu Yamamoto's avatar Hirokazu Yamamoto

Issue #4183: Some tests didn't run with pickle.HIGHEST_PROTOCOL.

Reviewed by Benjamin Peterson.
parent 369e2057
...@@ -397,7 +397,7 @@ class BaseBytesTest(unittest.TestCase): ...@@ -397,7 +397,7 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(b.rpartition(b'i'), (b'mississipp', b'i', b'')) self.assertEqual(b.rpartition(b'i'), (b'mississipp', b'i', b''))
def test_pickling(self): def test_pickling(self):
for proto in range(pickle.HIGHEST_PROTOCOL): for proto in range(pickle.HIGHEST_PROTOCOL + 1):
for b in b"", b"a", b"abc", b"\xffab\x80", b"\0\0\377\0\0": for b in b"", b"a", b"abc", b"\xffab\x80", b"\0\0\377\0\0":
b = self.type2test(b) b = self.type2test(b)
ps = pickle.dumps(b, proto) ps = pickle.dumps(b, proto)
...@@ -979,7 +979,7 @@ class ByteArraySubclassTest(unittest.TestCase): ...@@ -979,7 +979,7 @@ class ByteArraySubclassTest(unittest.TestCase):
a = ByteArraySubclass(b"abcd") a = ByteArraySubclass(b"abcd")
a.x = 10 a.x = 10
a.y = ByteArraySubclass(b"efgh") a.y = ByteArraySubclass(b"efgh")
for proto in range(pickle.HIGHEST_PROTOCOL): for proto in range(pickle.HIGHEST_PROTOCOL + 1):
b = pickle.loads(pickle.dumps(a, proto)) b = pickle.loads(pickle.dumps(a, proto))
self.assertNotEqual(id(a), id(b)) self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b) self.assertEqual(a, b)
......
...@@ -65,7 +65,7 @@ class RangeTest(unittest.TestCase): ...@@ -65,7 +65,7 @@ class RangeTest(unittest.TestCase):
def test_pickling(self): def test_pickling(self):
testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1), testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
(13, 21, 3), (-2, 2, 2)] (13, 21, 3), (-2, 2, 2)]
for proto in range(pickle.HIGHEST_PROTOCOL): for proto in range(pickle.HIGHEST_PROTOCOL + 1):
for t in testcases: for t in testcases:
r = range(*t) r = range(*t)
self.assertEquals(list(pickle.loads(pickle.dumps(r, proto))), self.assertEquals(list(pickle.loads(pickle.dumps(r, proto))),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment