]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
gen_test: Add test for asyncio.gather
authorBen Darnell <ben@bendarnell.com>
Sun, 21 Jan 2018 20:27:34 +0000 (15:27 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 21 Jan 2018 20:27:34 +0000 (15:27 -0500)
This is additional verification that the asyncio integration is
working as intended.

Fixes #1684

tornado/test/gen_test.py

index ff7d9770a00a343087c5869fa9679f60363aaae2..6850af81c84d5949f98a5760a9461e641a06339e 100644 (file)
@@ -1069,6 +1069,20 @@ class GenCoroutineTest(AsyncTestCase):
         actual = repr(coro)
         self.assertIn(expected, actual)
 
+    @unittest.skipIf(asyncio is None, "asyncio module not present")
+    @gen_test
+    def test_asyncio_gather(self):
+        # This demonstrates that tornado coroutines can be understood
+        # by asyncio (This failed prior to Tornado 5.0).
+        @gen.coroutine
+        def f():
+            yield gen.moment
+            raise gen.Return(1)
+
+        ret = yield asyncio.gather(f(), f())
+        self.assertEqual(ret, [1, 1])
+        self.finished = True
+
 
 class GenSequenceHandler(RequestHandler):
     @asynchronous