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

Function test_oserror_on_write_bytes

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

Source from the content-addressed store, hash-verified

1333
1334
1335async def test_oserror_on_write_bytes(loop, conn) -> None:
1336 req = ClientRequest("POST", URL("http://python.org/"), loop=loop)
1337 req.body = b"test data" # type: ignore[assignment] # https://github.com/python/mypy/issues/12892
1338
1339 writer = WriterMock()
1340 writer.write.side_effect = OSError
1341
1342 await req.write_bytes(writer, conn, None)
1343
1344 assert conn.protocol.set_exception.called
1345 exc = conn.protocol.set_exception.call_args[0][0]
1346 assert isinstance(exc, aiohttp.ClientOSError)
1347
1348 await req.close()
1349
1350
1351@pytest.mark.skipif(sys.version_info < (3, 11), reason="Needs Task.cancelling()")

Callers

nothing calls this directly

Calls 4

write_bytesMethod · 0.95
closeMethod · 0.95
ClientRequestClass · 0.90
WriterMockClass · 0.70

Tested by

no test coverage detected