From 528ebe97cfceafbb818c56da3f60cafce9eec56c Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 26 Mar 2017 11:57:09 -0400 Subject: [PATCH] gen: Add tests for `yield None` See #1716 --- tornado/test/gen_test.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index 73ccd4e9..bdaf889b 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -276,6 +276,13 @@ class GenEngineTest(AsyncTestCase): pass self.orphaned_callback() + def test_none(self): + @gen.engine + def f(): + yield None + self.stop() + self.run_gen(f) + def test_multi(self): @gen.engine def f(): @@ -752,6 +759,21 @@ class GenCoroutineTest(AsyncTestCase): self.assertEqual(result, 42) self.finished = True + @skipBefore35 + @gen_test + def test_asyncio_sleep_zero(self): + # asyncio.sleep(0) turns into a special case (equivalent to + # `yield None`) + namespace = exec_test(globals(), locals(), """ + async def f(): + import asyncio + await asyncio.sleep(0) + return 42 + """) + result = yield namespace['f']() + self.assertEqual(result, 42) + self.finished = True + @skipBefore35 @gen_test def test_async_await_mixed_multi_native_future(self):