Skip to content

Commit 88bc05e

Browse files
committed
Add test for _tee iterator pickling
1 parent 577efb6 commit 88bc05e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_pickle.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -57,5 +57,14 @@ def pickle_unpickle(self, obj):
5757
r_obj = pickle.loads(b_obj)
5858
self.assertEqual(r_obj, obj)
5959

60+
def test_teeiterator(self):
61+
import itertools
62+
teeit = itertools.tee([i for i in range(1, 20)])[0]
63+
[next(teeit) for i in range(1, 16)]
64+
b_obj = pickle.dumps(teeit, protocol=0)
65+
teeit2 = pickle.loads(b_obj)
66+
assert [16,17,18,19] == [next(teeit2) for i in range(1, 5)]
67+
assert [16,17,18,19] == [next(teeit) for i in range(1, 5)]
68+
6069
if __name__ == '__main__':
6170
unittest.main()

0 commit comments

Comments
 (0)