summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_itertools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-11-30 21:55:17 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-11-30 21:55:17 (GMT)
commit6c8ee7a33309b79d9f2737616501835349cfcdaf (patch)
tree934ecb458f43c5b729cd95d28d688210244c672a /Lib/test/test_itertools.py
parent9aeb9df7dae60b570e3a2f64a58fd605ce143d9c (diff)
downloadcpython-6c8ee7a33309b79d9f2737616501835349cfcdaf.zip
cpython-6c8ee7a33309b79d9f2737616501835349cfcdaf.tar.gz
cpython-6c8ee7a33309b79d9f2737616501835349cfcdaf.tar.bz2
Issue #7410: deepcopy of itertools.count was resetting the count.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r--Lib/test/test_itertools.py9
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)),