mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
tests/basics: Improve test coverage for generators.
This commit is contained in:
@@ -85,3 +85,17 @@ try:
|
||||
print(next(g))
|
||||
except StopIteration:
|
||||
print("StopIteration")
|
||||
|
||||
# case where generator ignores the close request and yields instead
|
||||
def gen7():
|
||||
try:
|
||||
yield 123
|
||||
except GeneratorExit:
|
||||
yield 456
|
||||
|
||||
g = gen7()
|
||||
print(next(g))
|
||||
try:
|
||||
g.close()
|
||||
except RuntimeError:
|
||||
print('RuntimeError')
|
||||
|
||||
Reference in New Issue
Block a user