diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2019-10-18 09:40:50 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2019-10-18 09:40:50 +0200 |
commit | be53f1234bec0bca4c35f020905e24d0637b91e3 (patch) | |
tree | b451761744d5c61c99e434d7e0285748c6a5490a | |
parent | 758aaad041dddef318f7eb476612d66eb8f7d082 (diff) | |
download | cython-be53f1234bec0bca4c35f020905e24d0637b91e3.tar.gz |
Add an explicit test for async-def functions with decorators.
Closes GH-1462.
-rw-r--r-- | tests/run/coroutines.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/run/coroutines.py b/tests/run/coroutines.py index d0b9ab9db..3b236a925 100644 --- a/tests/run/coroutines.py +++ b/tests/run/coroutines.py @@ -1,6 +1,6 @@ # cython: language_level=3 # mode: run -# tag: pep492, pure3.5 +# tag: pep492, pure3.5, gh1462, async, await async def test_coroutine_frame(awaitable): @@ -28,3 +28,33 @@ async def test_coroutine_frame(awaitable): """ b = await awaitable return b + + +# gh1462: Using decorators on coroutines. + +def pass_through(func): + return func + + +@pass_through +async def test_pass_through(): + """ + >>> t = test_pass_through() + >>> try: t.send(None) + ... except StopIteration as ex: + ... print(ex.args[0] if ex.args else None) + ... else: print("NOT STOPPED!") + None + """ + + +@pass_through(pass_through) +async def test_pass_through_with_args(): + """ + >>> t = test_pass_through_with_args() + >>> try: t.send(None) + ... except StopIteration as ex: + ... print(ex.args[0] if ex.args else None) + ... else: print("NOT STOPPED!") + None + """ |