mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #14288: Serialization support for builtin iterators.
This commit is contained in:
parent
283b96b6bd
commit
31668b8f7a
28 changed files with 2190 additions and 104 deletions
|
@ -285,6 +285,20 @@ class BaseTest(unittest.TestCase):
|
|||
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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue