diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:06:02 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:06:02 (GMT) |
commit | 65ee4674e290ba893509f51f192dd1c9aa3a0422 (patch) | |
tree | c1e960162df4444ff18a2ad3aff11d713ef9ea12 /Lib/test/test_bytes.py | |
parent | 0e32ea1089059a15b04a40c43bfe671e38ae16e7 (diff) | |
parent | bad1257c96943dcb39584a41e1a178542479df97 (diff) | |
download | cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.zip cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.gz cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.bz2 |
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index ef4af9c..e8dde5d 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -555,22 +555,23 @@ class BaseBytesTest: self.assertEqual(b, q) def test_iterator_pickling(self): - for b in b"", b"a", b"abc", b"\xffab\x80", b"\0\0\377\0\0": - it = itorg = iter(self.type2test(b)) - data = list(self.type2test(b)) - d = pickle.dumps(it) - it = pickle.loads(d) - self.assertEqual(type(itorg), type(it)) - self.assertEqual(list(it), data) - - it = pickle.loads(d) - try: - next(it) - except StopIteration: - continue - d = pickle.dumps(it) - it = pickle.loads(d) - self.assertEqual(list(it), data[1:]) + 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": + it = itorg = iter(self.type2test(b)) + data = list(self.type2test(b)) + d = pickle.dumps(it, proto) + it = pickle.loads(d) + self.assertEqual(type(itorg), type(it)) + self.assertEqual(list(it), data) + + it = pickle.loads(d) + try: + next(it) + except StopIteration: + continue + d = pickle.dumps(it, proto) + it = pickle.loads(d) + self.assertEqual(list(it), data[1:]) def test_strip(self): b = self.type2test(b'mississippi') |