def test_wrap_callback(self, mocker): # Setup c = AiohttpClient() mocker.spy(c, "_sync_callback_adapter") # Run: with callback that is not a coroutine def callback(*_): pass c.wrap_callback(callback) # Verify: Should wrap it c._sync_callback_adapter.assert_called_with(callback) # Run: with coroutine callback async def awaitable_callback(): pass assert c.wrap_callback(awaitable_callback) is awaitable_callback
def test_wrap_callback(self, mocker): import asyncio # Setup c = AiohttpClient() mocker.spy(c, "_sync_callback_adapter") # Run: with callback that is not a coroutine def callback(*_): pass c.wrap_callback(callback) # Verify: Should wrap it c._sync_callback_adapter.assert_called_with(callback) # Run: with coroutine callback coroutine_callback = asyncio.coroutine(callback) assert c.wrap_callback(coroutine_callback) is coroutine_callback