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

Function test_request_form_context_manager

tests/test_requests.py:135–145  ·  tests/test_requests.py::test_request_form_context_manager
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

133
134
135def test_request_form_context_manager(test_client_factory: TestClientFactory) -> None:
136 async def app(scope: Scope, receive: Receive, send: Send) -> None:
137 request = Request(scope, receive)
138 async with request.form() as form:
139 response = JSONResponse({class="st">"form": dict(form)})
140 await response(scope, receive, send)
141
142 client = test_client_factory(app)
143
144 response = client.post(class="st">"/", data={class="st">"abc": class="st">"123 @"})
145 assert response.json() == {class="st">"form": {class="st">"abc": class="st">"123 @"}}
146
147
148def test_request_body_then_stream(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
postMethod · 0.45

Tested by

no test coverage detected