Skip to content

Commit 698e9a8

Browse files
authored
bpo-44017: Update test_contextlib_async not to emit DeprecationWarn (pythonGH-25918)
1 parent 985ac01 commit 698e9a8

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Diff for: Lib/test/test_contextlib_async.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,14 @@ class TestAsyncExitStack(TestBaseExitStack, unittest.TestCase):
369369
class SyncAsyncExitStack(AsyncExitStack):
370370
@staticmethod
371371
def run_coroutine(coro):
372-
loop = asyncio.get_event_loop()
373-
374-
f = asyncio.ensure_future(coro)
375-
f.add_done_callback(lambda f: loop.stop())
372+
loop = asyncio.get_event_loop_policy().get_event_loop()
373+
t = loop.create_task(coro)
374+
t.add_done_callback(lambda f: loop.stop())
376375
loop.run_forever()
377376

378-
exc = f.exception()
379-
377+
exc = t.exception()
380378
if not exc:
381-
return f.result()
379+
return t.result()
382380
else:
383381
context = exc.__context__
384382

Diff for: Lib/unittest/test/testmock/testasync.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def foo(): pass
173173

174174
def test_future_isfuture(self):
175175
loop = asyncio.new_event_loop()
176-
asyncio.set_event_loop(loop)
177-
fut = asyncio.Future()
176+
fut = loop.create_future()
178177
loop.stop()
179178
loop.close()
180179
mock = AsyncMock(fut)

0 commit comments

Comments
 (0)