MCPcopy
hub / github.com/encode/starlette / test_request_headers

Function test_request_headers

tests/test_requests.py:48–65  ·  tests/test_requests.py::test_request_headers
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

46 reason=&class="cm">#x27;urllib3 includes class="st">"br" to the class="st">"accept-encoding" headers.',
47)
48def test_request_headers(test_client_factory: TestClientFactory) -> None:
49 async def app(scope: Scope, receive: Receive, send: Send) -> None:
50 request = Request(scope, receive)
51 headers = dict(request.headers)
52 response = JSONResponse({class="st">"headers": headers})
53 await response(scope, receive, send)
54
55 client = test_client_factory(app)
56 response = client.get(class="st">"/", headers={class="st">"host": class="st">"example.org"})
57 assert response.json() == {
58 class="st">"headers": {
59 class="st">"host": class="st">"example.org",
60 class="st">"user-agent": class="st">"testclient",
61 class="st">"accept-encoding": class="st">"gzip, deflate, zstd",
62 class="st">"accept": class="st">"*/*",
63 class="st">"connection": class="st">"keep-alive",
64 }
65 }
66
67
68@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected