diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-05-24 14:07:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 14:07:59 (GMT) |
commit | a6ee7f99cc3344e130383b7cf070723ff47ea99c (patch) | |
tree | f8424d26701c44075ae8b00280ec6d364ec509eb | |
parent | 719edfaf794a8c117c31f7bbe97d9afc2effbac4 (diff) | |
download | cpython-a6ee7f99cc3344e130383b7cf070723ff47ea99c.zip cpython-a6ee7f99cc3344e130383b7cf070723ff47ea99c.tar.gz cpython-a6ee7f99cc3344e130383b7cf070723ff47ea99c.tar.bz2 |
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>
-rw-r--r-- | Lib/test/test_contextlib_async.py | 11 |
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): |