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

Function test_request_state

tests/test_requests.py:328–337  ·  tests/test_requests.py::test_request_state
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

326
327
328def test_request_state(test_client_factory: TestClientFactory) -> None:
329 async def app(scope: Scope, receive: Receive, send: Send) -> None:
330 request = Request(scope, receive)
331 request.state.example = 123
332 response = JSONResponse({class="st">"state.example": request.state.example})
333 await response(scope, receive, send)
334
335 client = test_client_factory(app)
336 response = client.get(class="st">"/123?a=abc")
337 assert response.json() == {class="st">"state.example": 123}
338
339
340def test_request_cookies(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected