Skip to content

Commit c97bce7

Browse files
committed
chore: added unit test
1 parent ed2937a commit c97bce7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test-data/unit/check-async-await.test

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,13 +1013,15 @@ async def foo(x: int) -> int: ...
10131013

10141014
# These are allowed in some cases:
10151015
top_level = await foo(1) # E: "await" outside function [top-level-await]
1016-
crasher = [await foo(x) for x in [1, 2, 3]] # E: "await" outside function [top-level-await]
1016+
crasher = [await foo(x) for x in [1, 2, 3]] # E: "async for" outside async function [syntax] \
1017+
# E: "await" outside function [top-level-await]
10171018

10181019
def bad() -> None:
10191020
# These are always critical / syntax issues:
1020-
y = [await foo(x) for x in [1, 2, 3]] # E: "await" outside coroutine ("async def") [await-not-async]
1021+
y = [await foo(x) for x in [1, 2, 3]] # E: "async for" outside async function [syntax]
10211022
async def good() -> None:
10221023
y = [await foo(x) for x in [1, 2, 3]] # OK
1024+
10231025
[builtins fixtures/async_await.pyi]
10241026
[typing fixtures/typing-async.pyi]
10251027

@@ -1080,3 +1082,13 @@ class Launcher(P):
10801082

10811083
[builtins fixtures/async_await.pyi]
10821084
[typing fixtures/typing-async.pyi]
1085+
1086+
[case testAwaitInsideGeneratorExpr]
1087+
def foo():
1088+
yield 0
1089+
1090+
def bar():
1091+
(await x for x in foo())
1092+
1093+
[builtins fixtures/async_await.pyi]
1094+
[typing fixtures/typing-async.pyi]

0 commit comments

Comments
 (0)