tests: Add test where __getitem__ raises IndexError to stop iteration.
This commit is contained in:
parent
6433f71e8f
commit
c2ec2ad8fb
@ -21,6 +21,12 @@ try:
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
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
|
# this class raises a non-StopIteration exception on iteration
|
||||||
class A:
|
class A:
|
||||||
def __getitem__(self, i):
|
def __getitem__(self, i):
|
||||||
|
Loading…
Reference in New Issue
Block a user