diff options
| author | Kenny <3454741+WarriorOfWire@users.noreply.github.com> | 2020-07-21 00:01:22 -0700 |
|---|---|---|
| committer | Kenny <3454741+WarriorOfWire@users.noreply.github.com> | 2020-07-23 20:40:16 -0700 |
| commit | 51a79b1af7fa663bb078136611705c04df12970a (patch) | |
| tree | 69e15aa9c69c8383885ff899d67b584e2a060935 /tests | |
| parent | 543708416bc19bc1e77d859d013c4757433ad255 (diff) | |
add coroutine behavior for generators
coroutines don't have __next__; they also call themselves coroutines.
This does not change the fact that `async def` methods are generators,
but it does make them behave more like CPython.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/async_coroutine.py | 13 | ||||
| -rw-r--r-- | tests/basics/async_coroutine.py.exp | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/async_coroutine.py b/tests/basics/async_coroutine.py new file mode 100644 index 000000000..791f6df14 --- /dev/null +++ b/tests/basics/async_coroutine.py @@ -0,0 +1,13 @@ +async def f(): + pass + +try: + f() # Should not crash +except Exception as e: + print('failed to invoke') + +try: + next(f()) + print('This should fail because async def returns a coroutine, and next() is not allowed') +except Exception as e: + print('pass') diff --git a/tests/basics/async_coroutine.py.exp b/tests/basics/async_coroutine.py.exp new file mode 100644 index 000000000..2ae28399f --- /dev/null +++ b/tests/basics/async_coroutine.py.exp @@ -0,0 +1 @@ +pass |
