summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-08-30 11:48:06 +0100
committerDamien George <damien.p.george@gmail.com>2015-08-30 11:49:59 +0100
commitc2ec2ad8fbbd684d2820dbdc1f1198a8cd7f64e0 (patch)
treea504e3adc75ece915ca0788c66ba019d98d7de8d
parent6433f71e8fbf54a035aa1a735f6f2e5c1c71e922 (diff)
downloadmicropython-c2ec2ad8fbbd684d2820dbdc1f1198a8cd7f64e0.tar.gz
micropython-c2ec2ad8fbbd684d2820dbdc1f1198a8cd7f64e0.zip
tests: Add test where __getitem__ raises IndexError to stop iteration.
-rw-r--r--tests/basics/getitem.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basics/getitem.py b/tests/basics/getitem.py
index 3029f83035..4944641d15 100644
--- a/tests/basics/getitem.py
+++ b/tests/basics/getitem.py
@@ -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):