Skip to content

Commit d2ef66a

Browse files
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
Use asyncio.run().
1 parent 37c9a35 commit d2ef66a

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
@@ -15,15 +15,12 @@ def _async_test(func):
1515
@functools.wraps(func)
1616
def wrapper(*args, **kwargs):
1717
coro = func(*args, **kwargs)
18-
loop = asyncio.new_event_loop()
19-
asyncio.set_event_loop(loop)
20-
try:
21-
return loop.run_until_complete(coro)
22-
finally:
23-
loop.close()
24-
asyncio.set_event_loop_policy(None)
18+
asyncio.run(coro)
2519
return wrapper
2620

21+
def tearDownModule():
22+
asyncio.set_event_loop_policy(None)
23+
2724

2825
class TestAbstractAsyncContextManager(unittest.TestCase):
2926

0 commit comments

Comments
 (0)