-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
Consider the following example:
import asyncio
from aiohttp import ClientSession
from aioresponses import aioresponses
async def main():
with aioresponses() as mock_responses:
mock_responses.post("http://1.2.3.4")
async def data_generator():
yield b"foo"
raise RuntimeError("this generator is never awaited")
async with (
ClientSession() as session,
session.post("http://1.2.3.4", data=data_generator()) as response,
):
print(response.status)
print(await response.text())
if __name__ == "__main__":
asyncio.run(main())I would expect a failure here because the generator for the request body raises an exception, but instead the code exits normally with a 200 response. It seems like aioresponses is never actually awaiting the request body generator.
In my current project this is a problem because it means that there is no test coverage for the generator.
Is there a workaround for this, or is this a bug that needs to be fixed in aioresponses?
Metadata
Metadata
Assignees
Labels
No labels