Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_bytes.py @ 76091:4ff234337e24
Issue #14288: Serialization support for builtin iterators.
| author | Kristján Valur Jónsson <kristjan@ccpgames.com> |
|---|---|
| date | Tue, 03 Apr 2012 10:49:41 +0000 |
| parents | db968ac2b82c |
| children | 06577f6b1c99 16285c1b4dda |
line wrap: on
line diff
--- a/Lib/test/test_bytes.py Tue Apr 03 09:16:46 2012 +0200 +++ b/Lib/test/test_bytes.py Tue Apr 03 10:49:41 2012 +0000 @@ -518,6 +518,24 @@ q = pickle.loads(ps) 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:]) + def test_strip(self): b = self.type2test(b'mississippi') self.assertEqual(b.strip(b'i'), b'mississipp')
