Skip to content

Commit 8c23356

Browse files
committed
tests: make testAsync work with Python 3.10
The test would previously yield "DeprecationWarning: There is no current event loop".
1 parent 7576f65 commit 8c23356

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

mypyc/test-data/run-misc.test

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[case testAsync]
44
import asyncio
5+
import sys
56

67
async def h() -> int:
78
return 1
@@ -13,17 +14,25 @@ async def g() -> int:
1314
async def f() -> int:
1415
return await g()
1516

16-
loop = asyncio.get_event_loop()
17-
result = loop.run_until_complete(f())
17+
if sys.version_info >= (3, 7):
18+
result = asyncio.run(f())
19+
else:
20+
loop = asyncio.get_event_loop()
21+
result = loop.run_until_complete(f())
1822
assert result == 1
1923

2024
[typing fixtures/typing-full.pyi]
2125

2226
[file driver.py]
2327
from native import f
2428
import asyncio
25-
loop = asyncio.get_event_loop()
26-
result = loop.run_until_complete(f())
29+
import sys
30+
31+
if sys.version_info >= (3, 7):
32+
result = asyncio.run(f())
33+
else:
34+
loop = asyncio.get_event_loop()
35+
result = loop.run_until_complete(f())
2736
assert result == 1
2837

2938
[case testMaybeUninitVar]

0 commit comments

Comments
 (0)