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

Function test_request_logging

tests/protocols/test_http.py:346–358  ·  tests/protocols/test_http.py::test_request_logging
(path: str, http_protocol_cls: type[HTTPProtocol], caplog: pytest.LogCaptureFixture)

Source from the content-addressed store, hash-verified

344
345@pytest.mark.parametrize(class="st">"path", [class="st">"/", class="st">"/?foo", class="st">"/?foo=bar", class="st">"/?foo=bar&baz=1"])
346async def test_request_logging(path: str, http_protocol_cls: type[HTTPProtocol], caplog: pytest.LogCaptureFixture):
347 get_request_with_query_string = bclass="st">"\r\n".join(
348 [fclass="st">"GET {path} HTTP/1.1".encode(class="st">"ascii"), bclass="st">"Host: example.org", bclass="st">"", bclass="st">""]
349 )
350 caplog.set_level(logging.INFO, logger=class="st">"uvicorn.access")
351 logging.getLogger(class="st">"uvicorn.access").propagate = True
352
353 app = Response(class="st">"Hello, world", media_type=class="st">"text/plain")
354
355 protocol = get_connected_protocol(app, http_protocol_cls, log_config=None)
356 protocol.data_received(get_request_with_query_string)
357 await protocol.loop.run_one()
358 assert f&class="cm">#x27;class="st">"GET {path} HTTP/1.1" 200' in caplog.records[0].message
359
360
361async def test_head_request(http_protocol_cls: type[HTTPProtocol]):

Callers

nothing calls this directly

Calls 5

ResponseClass · 0.90
joinMethod · 0.80
get_connected_protocolFunction · 0.70
data_receivedMethod · 0.45
run_oneMethod · 0.45

Tested by

no test coverage detected