Skip to content

Commit c077d32

Browse files
author
Guido van Rossum
committed
Tweak tests for async/await a bit.
1 parent 9e2a2eb commit c077d32

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ reveal_type(f()) # E: Revealed type is 'typing.Awaitable[builtins.int]'
1818
# options: fast_parser
1919
async def f() -> int:
2020
x = await f()
21+
reveal_type(x) # E: Revealed type is 'builtins.int'
2122
return x
2223
[builtins fixtures/async_await.py]
24+
[out]
25+
main: note: In function "f":
2326

2427
[case testAwaitDefaultContext]
2528
# options: fast_parser
26-
from typing import Any, TypeVar
29+
from typing import TypeVar
2730
T = TypeVar('T')
2831
async def f(x: T) -> T:
2932
y = await f(x)
@@ -47,7 +50,7 @@ main:6: error: Revealed type is 'Any'
4750

4851
[case testAwaitExplicitContext]
4952
# options: fast_parser
50-
from typing import Any, TypeVar
53+
from typing import TypeVar
5154
T = TypeVar('T')
5255
async def f(x: T) -> T:
5356
y = await f(x) # type: int
@@ -57,7 +60,7 @@ main: note: In function "f":
5760
main:5: error: Argument 1 to "f" has incompatible type "T"; expected "int"
5861
main:6: error: Revealed type is 'builtins.int'
5962

60-
[case testAwaitGeneratorError]
63+
[case testAwaitIteratorError]
6164
# options: fast_parser
6265
from typing import Any, Iterator
6366
def g() -> Iterator[Any]:
@@ -83,6 +86,17 @@ main:5: error: Incompatible types in await (actual type "int", expected Awaitabl
8386

8487
[case testAwaitResultError]
8588
# options: fast_parser
89+
async def g() -> int:
90+
return 0
91+
async def f() -> str:
92+
x = await g() # type: str
93+
[builtins fixtures/async_await.py]
94+
[out]
95+
main: note: In function "f":
96+
main:5: error: Incompatible types in assignment (expression has type "int", variable has type "str")
97+
98+
[case testAwaitReturnError]
99+
# options: fast_parser
86100
async def g() -> int:
87101
return 0
88102
async def f() -> str:

0 commit comments

Comments
 (0)