All Questions
Tagged with python-unittest.mock python-asyncio
4 questions
0
votes
1
answer
305
views
Using AsyncMock with context manager to assert await was called (python)
I am new to using asyncio in Python and I'm having trouble figuring out how to write a test which uses python-websockets (and asyncio). I want to have a client which connects to a websocket and sends ...
0
votes
1
answer
857
views
Python unittests: how to get an AsyncMock to block until a certain point
I have some async Python code I want to test, which include something like
async def task(self):
while True:
await self.thing.change()
...
self.run_callbacks()
In my test ...
0
votes
0
answers
172
views
How can we properly mock/stub async methods of a mocked class?
I want to mock/stub the async methods of the Connect class returned by websockets.client.connect; such as send and recv. I succeed in testing the instantiation of the class, but I can't seem to setup ...
16
votes
4
answers
23k
views
Python asyncio: how to mock __aiter__() method?
I have a code which is listening to messages on WebSocket using aiohttp.
It looks like:
async for msg in ws:
await self._ws_msg_handler.handle_message(ws, msg, _services)
Where ws is an ...