MCPcopy
hub / github.com/encode/httpx / test_multipart

Function test_multipart

tests/test_multipart.py:17–41  ·  view source on GitHub ↗
(value, output)

Source from the content-addressed store, hash-verified

15
16@pytest.mark.parametrize(("value,output"), (("abc", b"abc"), (b"abc", b"abc")))
17def test_multipart(value, output):
18 client = httpx.Client(transport=httpx.MockTransport(echo_request_content))
19
20 # Test with a single-value 'data' argument, and a plain file 'files' argument.
21 data = {"text": value}
22 files = {"file": io.BytesIO(b"<file content>")}
23 response = client.post("http://127.0.0.1:8000/", data=data, files=files)
24 boundary = response.request.headers["Content-Type"].split("boundary=")[-1]
25 boundary_bytes = boundary.encode("ascii")
26
27 assert response.status_code == 200
28 assert response.content == b"".join(
29 [
30 b"--" + boundary_bytes + b"\r\n",
31 b'Content-Disposition: form-data; name="text"\r\n',
32 b"\r\n",
33 b"abc\r\n",
34 b"--" + boundary_bytes + b"\r\n",
35 b'Content-Disposition: form-data; name="file"; filename="upload"\r\n',
36 b"Content-Type: application/octet-stream\r\n",
37 b"\r\n",
38 b"<file content>\r\n",
39 b"--" + boundary_bytes + b"--\r\n",
40 ]
41 )
42
43
44@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

postMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected