MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / test_data_stream_exc

Function test_data_stream_exc

tests/test_client_request.py:1196–1219  ·  view source on GitHub ↗
(loop, conn)

Source from the content-addressed store, hash-verified

1194
1195
1196async def test_data_stream_exc(loop, conn) -> None:
1197 fut = loop.create_future()
1198
1199 async def gen():
1200 yield b"binary data"
1201 await fut
1202
1203 req = ClientRequest("POST", URL("http://python.org/"), data=gen(), loop=loop)
1204 assert req.chunked
1205 assert req.headers["TRANSFER-ENCODING"] == "chunked"
1206
1207 async def throw_exc():
1208 await asyncio.sleep(0.01)
1209 fut.set_exception(ValueError)
1210
1211 loop.create_task(throw_exc())
1212
1213 async with await req.send(conn):
1214 assert req._writer is not None
1215 await req._writer
1216 # assert conn.close.called
1217 assert conn.protocol is not None
1218 assert conn.protocol.set_exception.called
1219 await req.close()
1220
1221
1222async def test_data_stream_exc_chain(loop, conn) -> None:

Callers

nothing calls this directly

Calls 5

sendMethod · 0.95
closeMethod · 0.95
ClientRequestClass · 0.90
throw_excFunction · 0.85
genFunction · 0.70

Tested by

no test coverage detected