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

Function test_multipart_explicit_boundary

tests/test_multipart.py:57–76  ·  view source on GitHub ↗
(header: str)

Source from the content-addressed store, hash-verified

55 ],
56)
57def test_multipart_explicit_boundary(header: str) -> None:
58 client = httpx.Client(transport=httpx.MockTransport(echo_request_content))
59
60 files = {"file": io.BytesIO(b"<file content>")}
61 headers = {"content-type": header}
62 response = client.post("http://127.0.0.1:8000/", files=files, headers=headers)
63 boundary_bytes = b"+++"
64
65 assert response.status_code == 200
66 assert response.request.headers["Content-Type"] == header
67 assert response.content == b"".join(
68 [
69 b"--" + boundary_bytes + b"\r\n",
70 b'Content-Disposition: form-data; name="file"; filename="upload"\r\n',
71 b"Content-Type: application/octet-stream\r\n",
72 b"\r\n",
73 b"<file content>\r\n",
74 b"--" + boundary_bytes + b"--\r\n",
75 ]
76 )
77
78
79@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

postMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected