diff options
author | Raymond Hettinger <python@rcn.com> | 2009-11-30 22:02:31 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-11-30 22:02:31 (GMT) |
commit | a3e1ad27a890c8104328851fdf37ad4a616a96e9 (patch) | |
tree | 67c683a05281d369771c28d58b4421887dbf65a7 /Lib/test/test_itertools.py | |
parent | 8e319fc511264a041cb498a47a651b9affc90805 (diff) | |
download | cpython-a3e1ad27a890c8104328851fdf37ad4a616a96e9.zip cpython-a3e1ad27a890c8104328851fdf37ad4a616a96e9.tar.gz cpython-a3e1ad27a890c8104328851fdf37ad4a616a96e9.tar.bz2 |
Issue 7410: deepcopy of itertools.count() reset the count.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 2f449da..16e65ca 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -7,6 +7,8 @@ from fractions import Fraction import sys import operator import random +import copy +import pickle from functools import reduce maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 @@ -352,6 +354,13 @@ class TestBasicOps(unittest.TestCase): r2 = 'count(%r)'.__mod__(i).replace('L', '') self.assertEqual(r1, r2) + # check copy, deepcopy, pickle + for value in -3, 3, maxsize-5, maxsize+5: + c = count(value) + self.assertEqual(next(copy.copy(c)), value) + self.assertEqual(next(copy.deepcopy(c)), value) + self.assertEqual(next(pickle.loads(pickle.dumps(c))), value) + def test_count_with_stride(self): self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)]) self.assertEqual(lzip('abc',count(start=2,step=3)), |