From 8dc2ec1513e90a8d23394f1c4ec3a07c4e057610 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 30 Mar 2016 21:01:26 +0300 Subject: Issue #26492: Added additional tests for exhausted iterators of mutable sequences. --- Lib/test/test_iter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Lib/test/test_iter.py') 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): -- cgit v1.2.1