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

Function test_upload_file_file_input

tests/test_datastructures.py:373–383  ·  view source on GitHub ↗

Test passing file/stream into the UploadFile constructor

()

Source from the content-addressed store, hash-verified

371
372@pytest.mark.anyio
373async def test_upload_file_file_input() -> None:
374 """Test passing file/stream into the UploadFile constructor"""
375 stream = io.BytesIO(b"data")
376 file = UploadFile(filename="file", file=stream, size=4)
377 assert await file.read() == b"data"
378 assert file.size == 4
379 await file.write(b" and more data!")
380 assert await file.read() == b""
381 assert file.size == 19
382 await file.seek(0)
383 assert await file.read() == b"data and more data!"
384
385
386@pytest.mark.anyio

Callers

nothing calls this directly

Calls 4

readMethod · 0.95
writeMethod · 0.95
seekMethod · 0.95
UploadFileClass · 0.90

Tested by

no test coverage detected