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

Function test_multipart_rewinds_files

tests/test_multipart.py:423–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

421
422
423def test_multipart_rewinds_files():
424 with tempfile.TemporaryFile() as upload:
425 upload.write(b"Hello, world!")
426
427 transport = httpx.MockTransport(echo_request_content)
428 client = httpx.Client(transport=transport)
429
430 files = {"file": upload}
431 response = client.post("http://127.0.0.1:8000/", files=files)
432 assert response.status_code == 200
433 assert b"\r\nHello, world!\r\n" in response.content
434
435 # POSTing the same file instance a second time should have the same content.
436 files = {"file": upload}
437 response = client.post("http://127.0.0.1:8000/", files=files)
438 assert response.status_code == 200
439 assert b"\r\nHello, world!\r\n" in response.content
440
441
442class TestHeaderParamHTML5Formatting:

Callers

nothing calls this directly

Calls 1

postMethod · 0.95

Tested by

no test coverage detected