I use aiohttp, pytest and pytest-cov to get coverage of my code. I want to get better coverage< but now I am a little bit stuck, because event simple code does not show 100% cov. For example this piece of code:
@session_decorator()
async def healthcheck(session, request):
await session.scalar("select pg_is_in_recovery();")
return web.json_response({"status": "ok"})
in coverage report it shows that line with return is not covered.
I have read this link Code coverage for async methods. But this is for C# and I can not understand:
This can happen most commonly if the operation you're awaiting is completed before it's awaited.
My code to run tests:
python3.9 -m pytest -vv --cov --cov-report xml --cov-report term-missing
My test for code above
async def test_healthz_page(test_client):
response = await test_client.get("/healthz")
assert response.status == HTTPStatus.OK