tests: Add test where __getitem__ raises IndexError to stop iteration.

This commit is contained in:
Damien George 2015-08-30 11:48:06 +01:00
parent 6433f71e8f
commit c2ec2ad8fb
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,12 @@ try:
except StopIteration:
pass
# this class raises an IndexError to stop the iteration
class A:
def __getitem__(self, i):
raise IndexError
print(list(A()))
# this class raises a non-StopIteration exception on iteration
class A:
def __getitem__(self, i):