Skip to content

Commit 502dba0

Browse files
GH-89369: test_contextlib_async finalizes event loop after each test (GH-93074)
Use asyncio.run(). (cherry picked from commit d2ef66a) Co-authored-by: Kumar Aditya <[email protected]>
1 parent db2b1e1 commit 502dba0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Lib/test/test_contextlib_async.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ def _async_test(func):
1414
@functools.wraps(func)
1515
def wrapper(*args, **kwargs):
1616
coro = func(*args, **kwargs)
17-
loop = asyncio.new_event_loop()
18-
asyncio.set_event_loop(loop)
19-
try:
20-
return loop.run_until_complete(coro)
21-
finally:
22-
loop.close()
23-
asyncio.set_event_loop_policy(None)
17+
asyncio.run(coro)
2418
return wrapper
2519

20+
def tearDownModule():
21+
asyncio.set_event_loop_policy(None)
22+
2623

2724
class TestAbstractAsyncContextManager(unittest.TestCase):
2825

0 commit comments

Comments
 (0)