diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-30 21:01:45 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-03-30 21:01:45 +0300 |
commit | f39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2 (patch) | |
tree | 28f2b61a6323d9b443f85de960f8b95efeec7376 /Lib/test/test_iter.py | |
parent | ab479c49d31be03e85b824b8444b474b28e6db71 (diff) | |
parent | 8dc2ec1513e90a8d23394f1c4ec3a07c4e057610 (diff) | |
download | cpython-git-f39c0ac62f90842b790a41f1b0ddd51a6e3d8dc2.tar.gz |
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 54ddbaa5fd..a91670b4a1 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): |