Issue #26492: Added additional tests for exhausted iterators of mutable sequences.

This commit is contained in:
Serhiy Storchaka 2016-03-30 21:01:26 +03:00
parent fbb1c5ee06
commit 8dc2ec1513
3 changed files with 24 additions and 0 deletions

View file

@ -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]))