mirror of
https://github.com/python/cpython.git
synced 2025-07-22 18:55:22 +00:00
GH-89369: test_contextlib_async finalizes event loop after each test (GH-93074)
Use asyncio.run().
(cherry picked from commit d2ef66a10b
)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
719edfaf79
commit
a6ee7f99cc
1 changed files with 4 additions and 7 deletions
|
@ -15,15 +15,12 @@ def _async_test(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
coro = func(*args, **kwargs)
|
coro = func(*args, **kwargs)
|
||||||
loop = asyncio.new_event_loop()
|
asyncio.run(coro)
|
||||||
asyncio.set_event_loop(loop)
|
|
||||||
try:
|
|
||||||
return loop.run_until_complete(coro)
|
|
||||||
finally:
|
|
||||||
loop.close()
|
|
||||||
asyncio.set_event_loop_policy(None)
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
def tearDownModule():
|
||||||
|
asyncio.set_event_loop_policy(None)
|
||||||
|
|
||||||
|
|
||||||
class TestAbstractAsyncContextManager(unittest.TestCase):
|
class TestAbstractAsyncContextManager(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue