[Python-checkins] GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
vstinner
webhook-mailer at python.org
Tue May 24 09:42:01 EDT 2022
https://github.com/python/cpython/commit/d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124
commit: d2ef66a10be1250b13c32fbf3c0f9a9d2d98b124
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2022-05-24T15:41:32+02:00
summary:
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
Use asyncio.run().
files:
M Lib/test/test_contextlib_async.py
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 76bd81c7d02cc..b64673d2c31e0 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):
More information about the Python-checkins
mailing list