Browse Source
bpo-44017: Update test_contextlib_async not to emit DeprecationWarn (GH-25918)
pull/25948/head
Dong-hee Na
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
6 additions and
9 deletions
-
Lib/test/test_contextlib_async.py
-
Lib/unittest/test/testmock/testasync.py
|
|
|
@ -369,16 +369,14 @@ class TestAsyncExitStack(TestBaseExitStack, unittest.TestCase): |
|
|
|
class SyncAsyncExitStack(AsyncExitStack): |
|
|
|
@staticmethod |
|
|
|
def run_coroutine(coro): |
|
|
|
loop = asyncio.get_event_loop() |
|
|
|
|
|
|
|
f = asyncio.ensure_future(coro) |
|
|
|
f.add_done_callback(lambda f: loop.stop()) |
|
|
|
loop = asyncio.get_event_loop_policy().get_event_loop() |
|
|
|
t = loop.create_task(coro) |
|
|
|
t.add_done_callback(lambda f: loop.stop()) |
|
|
|
loop.run_forever() |
|
|
|
|
|
|
|
exc = f.exception() |
|
|
|
|
|
|
|
exc = t.exception() |
|
|
|
if not exc: |
|
|
|
return f.result() |
|
|
|
return t.result() |
|
|
|
else: |
|
|
|
context = exc.__context__ |
|
|
|
|
|
|
|
|
|
|
|
@ -173,8 +173,7 @@ class AsyncMockTest(unittest.TestCase): |
|
|
|
|
|
|
|
def test_future_isfuture(self): |
|
|
|
loop = asyncio.new_event_loop() |
|
|
|
asyncio.set_event_loop(loop) |
|
|
|
fut = asyncio.Future() |
|
|
|
fut = loop.create_future() |
|
|
|
loop.stop() |
|
|
|
loop.close() |
|
|
|
mock = AsyncMock(fut) |
|
|
|
|