Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_array.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 | 98c0265cf7b9 |
| children | e0f3406c43e4 |
line wrap: on
line diff
--- a/Lib/test/test_array.py Tue Apr 03 09:16:46 2012 +0200 +++ b/Lib/test/test_array.py Tue Apr 03 10:49:41 2012 +0000 @@ -285,6 +285,20 @@ self.assertEqual(a.x, b.x) self.assertEqual(type(a), type(b)) + def test_iterator_pickle(self): + data = array.array(self.typecode, self.example) + orgit = iter(data) + d = pickle.dumps(orgit) + it = pickle.loads(d) + self.assertEqual(type(orgit), type(it)) + self.assertEqual(list(it), list(data)) + + if len(data): + it = pickle.loads(d) + next(it) + d = pickle.dumps(it) + self.assertEqual(list(it), list(data)[1:]) + def test_insert(self): a = array.array(self.typecode, self.example) a.insert(0, self.example[0])
