mirror of https://github.com/python/cpython
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
Use asyncio.run().
This commit is contained in:
parent
37c9a351b1
commit
d2ef66a10b
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue