From 0ea2108f1cb4ab889e780fdff2ad0730290950e0 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 28 Apr 2016 02:07:42 +0300 Subject: [PATCH] tests: Add testcase for yielding from a stopped generator. --- tests/basics/gen_yield_from_stopped.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/basics/gen_yield_from_stopped.py 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")