diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-04-28 02:07:42 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-04-28 02:08:51 +0300 |
commit | 0ea2108f1cb4ab889e780fdff2ad0730290950e0 (patch) | |
tree | e3dffb00eca94a270b422c21f98e953b19d9f575 /tests/basics/gen_yield_from_stopped.py | |
parent | eff85bb1dcca0602cef055986ea3b8192dea1d71 (diff) | |
download | micropython-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.py | 18 |
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") |