From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 24 May 2022 14:25:50 +0000 (-0700) Subject: GH-89369: test_contextlib_async finalizes event loop after each test (GH-93074) X-Git-Tag: v3.10.5~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=502dba0cf38ebd657d444fd49b8d648fe86bbb7d;p=thirdparty%2FPython%2Fcpython.git GH-89369: test_contextlib_async finalizes event loop after each test (GH-93074) Use asyncio.run(). (cherry picked from commit d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py index d6a34e22ac42..d44d36209c70 100644 --- a/Lib/test/test_contextlib_async.py +++ b/Lib/test/test_contextlib_async.py @@ -14,15 +14,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):