From: A. Jesse Jiryu Davis Date: Thu, 9 Feb 2017 01:23:39 +0000 (-0500) Subject: Avoid deprecated asyncio.async() in test X-Git-Tag: v4.5.0~40^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=043e795ec62eb57ae8f12a718ca08d0f5c783948;p=thirdparty%2Ftornado.git Avoid deprecated asyncio.async() in test --- 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)