I am trying to write pytest for the following async, await methods but I am getting nowhere.
class UserDb(object):
async def add_user_info(self,userInfo):
return await self.post_route(route='users',json=userInfo)
async def post_route(self,route=None,json=None,params=None):
uri = self.uri + route if route else self.uri
async with self.client.post(uri,json=json,params=params) as resp:
assert resp.status == 200
return await resp.json()
Can someone help me with this? TIA
pip install pytest-aiohttp
, then create a fixture like thisNow write your tests
Also I noticed your
add_user_info
coroutine isn't returning anything. More info is here