diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-30 18:01:26 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-30 18:01:26 (GMT) |
commit | 8dc2ec1513e90a8d23394f1c4ec3a07c4e057610 (patch) | |
tree | 9ab12f22a0ce6dd8a08a84aa7bd9c99fc21506db /Lib/test/test_iter.py | |
parent | fbb1c5ee068d209e33f6e15ecb4821d5d8b107fa (diff) | |
download | cpython-8dc2ec1513e90a8d23394f1c4ec3a07c4e057610.zip cpython-8dc2ec1513e90a8d23394f1c4ec3a07c4e057610.tar.gz cpython-8dc2ec1513e90a8d23394f1c4ec3a07c4e057610.tar.bz2 |
Issue #26492: Added additional tests for exhausted iterators of mutable sequences.
Diffstat (limited to 'Lib/test/test_iter.py')
-rw-r--r-- | Lib/test/test_iter.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py index 54ddbaa..a91670b 100644 --- a/Lib/test/test_iter.py +++ b/Lib/test/test_iter.py @@ -190,6 +190,17 @@ class TestCase(unittest.TestCase): self.assertTrue(isinstance(it, collections.abc.Iterator)) self.assertEqual(list(it), []) + def test_mutating_seq_class_exhausted_iter(self): + a = SequenceClass(5) + exhit = iter(a) + empit = iter(a) + for x in exhit: # exhaust the iterator + next(empit) # not exhausted + a.n = 7 + self.assertEqual(list(exhit), []) + self.assertEqual(list(empit), [5, 6]) + self.assertEqual(list(a), [0, 1, 2, 3, 4, 5, 6]) + # Test a new_style class with __iter__ but no next() method def test_new_style_iter_class(self): class IterClass(object): |