]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Tue, 24 May 2022 13:41:32 +0000 (19:11 +0530)
committerGitHub <noreply@github.com>
Tue, 24 May 2022 13:41:32 +0000 (15:41 +0200)
Use asyncio.run().

Lib/test/test_contextlib_async.py

index 76bd81c7d02ccd8e4c40e8b4a688c035e341573a..b64673d2c31e05672f566699fc0546c7afb58b77 100644 (file)
@@ -15,15 +15,12 @@ def _async_test(func):
     @functools.wraps(func)
     def wrapper(*args, **kwargs):
         coro = func(*args, **kwargs)
-        loop = asyncio.new_event_loop()
-        asyncio.set_event_loop(loop)
-        try:
-            return loop.run_until_complete(coro)
-        finally:
-            loop.close()
-            asyncio.set_event_loop_policy(None)
+        asyncio.run(coro)
     return wrapper
 
+def tearDownModule():
+    asyncio.set_event_loop_policy(None)
+
 
 class TestAbstractAsyncContextManager(unittest.TestCase):