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

Function test_multipart_request_files

tests/test_formparsers.py:157–172  ·  view source on GitHub ↗
(tmpdir: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

155
156
157def test_multipart_request_files(tmpdir: Path, test_client_factory: TestClientFactory) -> None:
158 path = os.path.join(tmpdir, "test.txt")
159 with open(path, "wb") as file:
160 file.write(b"<file content>")
161
162 client = test_client_factory(app)
163 with open(path, "rb") as f:
164 response = client.post("/", files={"test": f})
165 assert response.json() == {
166 "test": {
167 "filename": "test.txt",
168 "size": 14,
169 "content": "<file content>",
170 "content_type": "text/plain",
171 }
172 }
173
174
175def test_multipart_request_files_with_content_type(tmpdir: Path, test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

test_client_factoryFunction · 0.85
jsonMethod · 0.80
writeMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected