summaryrefslogtreecommitdiffstats
path: root/Lib/test/list_tests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-30 18:01:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-30 18:01:45 (GMT)
commitf39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2 (patch)
tree28f2b61a6323d9b443f85de960f8b95efeec7376 /Lib/test/list_tests.py
parentab479c49d31be03e85b824b8444b474b28e6db71 (diff)
parent8dc2ec1513e90a8d23394f1c4ec3a07c4e057610 (diff)
downloadcpython-f39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2.zip
cpython-f39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2.tar.gz
cpython-f39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2.tar.bz2
Issue #26492: Added additional tests for exhausted iterators of mutable sequences.
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r--Lib/test/list_tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index 1adfc75..f20fdc0 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -593,3 +593,14 @@ class CommonTest(seq_tests.CommonTest):
def __iter__(self):
raise KeyboardInterrupt
self.assertRaises(KeyboardInterrupt, list, F())
+
+ def test_exhausted_iterator(self):
+ a = self.type2test([1, 2, 3])
+ exhit = iter(a)
+ empit = iter(a)
+ for x in exhit: # exhaust the iterator
+ next(empit) # not exhausted
+ a.append(9)
+ self.assertEqual(list(exhit), [])
+ self.assertEqual(list(empit), [9])
+ self.assertEqual(a, self.type2test([1, 2, 3, 9]))