MCPcopy
hub / github.com/encode/uvicorn / test_exception_during_response

Function test_exception_during_response

tests/protocols/test_http.py:548–558  ·  view source on GitHub ↗
(http_protocol_cls: type[HTTPProtocol])

Source from the content-addressed store, hash-verified

546
547
548async def test_exception_during_response(http_protocol_cls: type[HTTPProtocol]):
549 async def app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable):
550 await send({"type": "http.response.start", "status": 200})
551 await send({"type": "http.response.body", "body": b"1", "more_body": True})
552 raise Exception()
553
554 protocol = get_connected_protocol(app, http_protocol_cls)
555 protocol.data_received(SIMPLE_GET_REQUEST)
556 await protocol.loop.run_one()
557 assert b"HTTP/1.1 500 Internal Server Error" not in protocol.transport.buffer
558 assert protocol.transport.is_closing()
559
560
561async def test_no_response_returned(http_protocol_cls: type[HTTPProtocol]):

Callers

nothing calls this directly

Calls 4

get_connected_protocolFunction · 0.70
data_receivedMethod · 0.45
run_oneMethod · 0.45
is_closingMethod · 0.45

Tested by

no test coverage detected