pip install pytest-aiohttp, then create a tool like
from pytest import fixture
def make_app():
app = Application()
return app
@fixture
def test_fixture(loop, test_client):
"""Test fixture to be used in test cases"""
app = make_app()
return loop.run_until_complete(test_client(app))
Now write your tests
f = test_fixture
async def test_add_user_info(f):
resp = await f.get('/')
assert resp.status == 200
assert await resp.json() == {'some_key': 'some_value'}
I also noticed that your coroutine add_user_inforeturns nothing. More info here
source
share