Merge pull request #1986 from bdarnell/yield-none-test
gen: Add tests for `yield None`
This commit is contained in:
commit
d73210f092
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue