MCPcopy Index your code
hub / github.com/encode/starlette / test_upload_file_without_size

Function test_upload_file_without_size

tests/test_datastructures.py:387–397  ·  view source on GitHub ↗

Test passing file/stream into the UploadFile constructor without size

()

Source from the content-addressed store, hash-verified

385
386@pytest.mark.anyio
387async def test_upload_file_without_size() -> None:
388 """Test passing file/stream into the UploadFile constructor without size"""
389 stream = io.BytesIO(b"data")
390 file = UploadFile(filename="file", file=stream)
391 assert await file.read() == b"data"
392 assert file.size is None
393 await file.write(b" and more data!")
394 assert await file.read() == b""
395 assert file.size is None
396 await file.seek(0)
397 assert await file.read() == b"data and more data!"
398
399
400@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