======
:release-date: 2018-05-07 3:20 P.M PDT
:release-by: Ask Solem
- Adds new mock class for async functions: :func:`mode.utils.mocks.AsyncMock`
This can be used to mock an async callable::
from mode.utils.mocks import AsyncMock
class App(Service):
async def on_start(self):
self.ret = await self.some_async_method('arg')
async def some_async_method(self, arg):
await asyncio.sleep(1)
pytest.fixture
def app():
return App()
pytest.mark.asyncio
async def test_something(*, app):
app.some_async_method = AsyncMock()
async with app: starts and stops the service, calling on_start
app.some_async_method.assert_called_once_with('arg')
assert app.ret is app.some_async_method.coro.return_value
- Added 100% test coverage for modules:
+ :mod:`mode.proxy`
+ :mod:`mode.threads`
+ :mod:`mode.utils.aiter`
.. _version-1.12.3: