def recognizes_an_old_style_coroutine(): @asyncio.coroutine def some_old_style_coroutine(): yield False # pragma: no cover assert is_awaitable(some_old_style_coroutine()) assert is_awaitable(some_old_style_coroutine())
async def recognizes_a_future_object(): async def some_coroutine(): return False # pragma: no cover some_future = asyncio.ensure_future(some_coroutine()) assert is_awaitable(some_future) assert is_awaitable(some_future)
async def await_execution_results(): execution_results, all_params = self.run_http_query( request_method, data, catch) return [ ex if ex is None or not is_awaitable(ex) else await ex for ex in execution_results ], all_params
async def _complete(list_field): result = execute( build_schema("type Query { listField: [String] }"), parse("{ listField }"), Data(list_field), ) assert is_awaitable(result) result = cast(Awaitable, result) return await result
def declines_an_async_generator(): async def some_async_generator(): yield True # pragma: no cover assert not isawaitable(some_async_generator()) assert not is_awaitable(some_async_generator())
def declines_the_none_value(): assert not isawaitable(None) assert not is_awaitable(None)
async def recognizes_a_coroutine_object(): async def some_coroutine(): return False # pragma: no cover assert isawaitable(some_coroutine()) assert is_awaitable(some_coroutine())
def declines_a_coroutine_function(): async def some_coroutine(): return True # pragma: no cover assert not isawaitable(some_coroutine) assert not is_awaitable(some_coroutine)
def declines_an_int_value(): assert not is_awaitable(42)
def declines_a_normal_function(): def some_function(): return True assert not isawaitable(some_function()) assert not is_awaitable(some_function)
def declines_a_lambda_function(): assert not isawaitable(lambda: True) # pragma: no cover assert not is_awaitable(lambda: True) # pragma: no cover
def declines_the_type_class(): assert not isawaitable(type) assert not is_awaitable(type)
def declines_an_object_instance(): assert not isawaitable(object()) assert not is_awaitable(object())
def declines_a_dict_value(): assert not isawaitable({}) assert not is_awaitable({})
def declines_a_string_value(): assert not isawaitable("some_string") assert not is_awaitable("some_string")
def declines_a_normal_generator_object(): def some_generator(): yield True # pragma: no cover assert not isawaitable(some_generator()) assert not is_awaitable(some_generator())
def declines_a_boolean_value(): assert not isawaitable(True) assert not is_awaitable(True)