summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib_async.py
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-05-24 13:41:32 (GMT)
committerGitHub <noreply@github.com>2022-05-24 13:41:32 (GMT)
commitd2ef66a10be1250b13c32fbf3c0f9a9d2d98b124 (patch)
tree10a3d3d4a84cfa5e1f9ecdfb0562710aafc53588 /Lib/test/test_contextlib_async.py
parent37c9a351b15c3fc4fcdca5dcb9ce19e51d7d2dd7 (diff)
downloadcpython-d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124.zip
cpython-d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124.tar.gz
cpython-d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124.tar.bz2
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
Use asyncio.run().
Diffstat (limited to 'Lib/test/test_contextlib_async.py')
-rw-r--r--Lib/test/test_contextlib_async.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 76bd81c..b64673d 100644
--- a/Lib/test/test_contextlib_async.py
+++ b/Lib/test/test_contextlib_async.py
@@ -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):