mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
tests: Add testcase for yielding from a stopped generator.
This commit is contained in:
18
tests/basics/gen_yield_from_stopped.py
Normal file
18
tests/basics/gen_yield_from_stopped.py
Normal file
@@ -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")
|
||||
Reference in New Issue
Block a user