mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #26492: Added additional tests for exhausted iterators of mutable sequences.
This commit is contained in:
parent
fbb1c5ee06
commit
8dc2ec1513
3 changed files with 24 additions and 0 deletions
|
@ -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]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue