summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/gen_yield_from_stopped.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-04-28 02:07:42 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-04-28 02:08:51 +0300
commit0ea2108f1cb4ab889e780fdff2ad0730290950e0 (patch)
treee3dffb00eca94a270b422c21f98e953b19d9f575 /tests/basics/gen_yield_from_stopped.py
parenteff85bb1dcca0602cef055986ea3b8192dea1d71 (diff)
downloadmicropython-0ea2108f1cb4ab889e780fdff2ad0730290950e0.tar.gz
micropython-0ea2108f1cb4ab889e780fdff2ad0730290950e0.zip
tests: Add testcase for yielding from a stopped generator.
Diffstat (limited to 'tests/basics/gen_yield_from_stopped.py')
-rw-r--r--tests/basics/gen_yield_from_stopped.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/basics/gen_yield_from_stopped.py b/tests/basics/gen_yield_from_stopped.py
new file mode 100644
index 0000000000..468679b615
--- /dev/null
+++ b/tests/basics/gen_yield_from_stopped.py
@@ -0,0 +1,18 @@
+# Yielding from stopped generator is ok and results in None
+
+def gen():
+ return 1
+ # This yield is just to make this a generator
+ yield
+
+f = gen()
+
+def run():
+ print((yield from f))
+ print((yield from f))
+ print((yield from f))
+
+try:
+ next(run())
+except StopIteration:
+ print("StopIteration")