Skip to content

Commit c2ec2ad

Browse files
committed
tests: Add test where __getitem__ raises IndexError to stop iteration.
1 parent 6433f71 commit c2ec2ad

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/basics/getitem.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def __getitem__(self, index):
2121
except StopIteration:
2222
pass
2323

24+
# this class raises an IndexError to stop the iteration
25+
class A:
26+
def __getitem__(self, i):
27+
raise IndexError
28+
print(list(A()))
29+
2430
# this class raises a non-StopIteration exception on iteration
2531
class A:
2632
def __getitem__(self, i):

0 commit comments

Comments
 (0)