def test_threaded_response(self, mocker): # Setup import asyncio @asyncio.coroutine def coroutine(): return 1 response = mocker.Mock() response.text = coroutine threaded_response = aiohttp_.ThreadedResponse(response) # Run threaded_coroutine = threaded_response.text return_value = threaded_coroutine() # Verify assert isinstance(threaded_coroutine, aiohttp_.ThreadedCoroutine) assert return_value == 1
def test_threaded_response(self, mocker): async def coroutine(): return 1 def not_a_coroutine(): return 2 response = mocker.Mock() response.coroutine = coroutine response.not_coroutine = not_a_coroutine threaded_response = aiohttp_.ThreadedResponse(response) # Run threaded_coroutine = threaded_response.coroutine return_value = threaded_coroutine() # Verify assert isinstance(threaded_coroutine, aiohttp_.ThreadedCoroutine) assert return_value == 1 assert threaded_response.not_coroutine is not_a_coroutine