summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/gen_yield_from_throw2.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-01-17 00:17:44 +1100
committerDamien George <damien.p.george@gmail.com>2017-01-17 00:17:44 +1100
commit96baaa68a4430efd585f2186976cfa473ca73bfc (patch)
tree926f422e0eeb3af4adaef8a57e5a9e9ed774b00c /tests/basics/gen_yield_from_throw2.py
parent239f92029910cddb08a2669f3ebcd987f0a2d0a8 (diff)
downloadmicropython-96baaa68a4430efd585f2186976cfa473ca73bfc.tar.gz
micropython-96baaa68a4430efd585f2186976cfa473ca73bfc.zip
tests: Update tests, and add new ones, for recent generator tweaks.
Diffstat (limited to 'tests/basics/gen_yield_from_throw2.py')
-rw-r--r--tests/basics/gen_yield_from_throw2.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/basics/gen_yield_from_throw2.py b/tests/basics/gen_yield_from_throw2.py
index 2cff9e08ba..0abfdd8cc3 100644
--- a/tests/basics/gen_yield_from_throw2.py
+++ b/tests/basics/gen_yield_from_throw2.py
@@ -1,5 +1,5 @@
-# uPy differs from CPython for this test
-# generator ignored GeneratorExit
+# generator ignores a thrown GeneratorExit (this is allowed)
+
def gen():
try:
yield 123
@@ -7,9 +7,12 @@ def gen():
print('GeneratorExit')
yield 456
+# thrown a class
g = gen()
print(next(g))
-try:
- g.throw(GeneratorExit)
-except RuntimeError:
- print('RuntimeError')
+print(g.throw(GeneratorExit))
+
+# thrown an instance
+g = gen()
+print(next(g))
+print(g.throw(GeneratorExit()))