MCPcopy Create free account
hub / github.com/encode/starlette / test_upload_file_file_input

Function test_upload_file_file_input

tests/test_datastructures.py:425–435  ·  view source on GitHub ↗

Test passing file/stream into the UploadFile constructor

()

Source from the content-addressed store, hash-verified

423
424@pytest.mark.anyio
425async def test_upload_file_file_input() -> None:
426 """Test passing file/stream into the UploadFile constructor"""
427 stream = io.BytesIO(b"data")
428 file = UploadFile(filename="file", file=stream, size=4)
429 assert await file.read() == b"data"
430 assert file.size == 4
431 await file.write(b" and more data!")
432 assert await file.read() == b""
433 assert file.size == 19
434 await file.seek(0)
435 assert await file.read() == b"data and more data!"
436
437
438@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