summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_itertools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-06 12:00:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-06 12:00:45 (GMT)
commitd55162517da38138fed130607b311ed4cc62ec77 (patch)
tree71604a96a8a112d4636da05f16e990704db51dd2 /Lib/test/test_itertools.py
parenta01a144aab05b18b7f4d0e84d04b36b1677338ff (diff)
downloadcpython-d55162517da38138fed130607b311ed4cc62ec77.zip
cpython-d55162517da38138fed130607b311ed4cc62ec77.tar.gz
cpython-d55162517da38138fed130607b311ed4cc62ec77.tar.bz2
Issue #25718: Fixed pickling and copying the accumulate() iterator with total is None.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r--Lib/test/test_itertools.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 5b3ba7e..08c9f39 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1398,6 +1398,16 @@ class TestExamples(unittest.TestCase):
self.assertEqual(list(copy.deepcopy(it)), accumulated[1:])
self.assertEqual(list(copy.copy(it)), accumulated[1:])
+ def test_accumulate_reducible_none(self):
+ # Issue #25718: total is None
+ it = accumulate([None, None, None], operator.is_)
+ self.assertEqual(next(it), None)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ it_copy = pickle.loads(pickle.dumps(it, proto))
+ self.assertEqual(list(it_copy), [True, False])
+ self.assertEqual(list(copy.deepcopy(it)), [True, False])
+ self.assertEqual(list(copy.copy(it)), [True, False])
+
def test_chain(self):
self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')