tests/basics: Improve test coverage for generators.

This commit is contained in:
Rami Ali
2016-12-20 12:57:39 +11:00
committed by Damien George
parent 1e7a801e2d
commit 5d06a74303
6 changed files with 47 additions and 1 deletions

View File

@@ -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')