From 043e795ec62eb57ae8f12a718ca08d0f5c783948 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Wed, 8 Feb 2017 20:23:39 -0500 Subject: [PATCH] Avoid deprecated asyncio.async() in test --- tornado/test/asyncio_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tornado/test/asyncio_test.py b/tornado/test/asyncio_test.py index b50b2048e..6387b1112 100644 --- a/tornado/test/asyncio_test.py +++ b/tornado/test/asyncio_test.py @@ -41,8 +41,14 @@ class AsyncIOLoopTest(AsyncTestCase): @gen_test def test_asyncio_future(self): # Test that we can yield an asyncio future from a tornado coroutine. - # Without 'yield from', we must wrap coroutines in asyncio.async. - x = yield asyncio.async( + # Without 'yield from', we must wrap coroutines in ensure_future, + # which was introduced during Python 3.4, deprecating the prior "async". + if hasattr(asyncio, 'ensure_future'): + ensure_future = asyncio.ensure_future + else: + ensure_future = asyncio.async + + x = yield ensure_future( asyncio.get_event_loop().run_in_executor(None, lambda: 42)) self.assertEqual(x, 42) -- 2.47.2