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

Function test_upload_file_without_size

tests/test_datastructures.py:439–449  ·  view source on GitHub ↗

Test passing file/stream into the UploadFile constructor without size

()

Source from the content-addressed store, hash-verified

437
438@pytest.mark.anyio
439async def test_upload_file_without_size() -> None:
440 """Test passing file/stream into the UploadFile constructor without size"""
441 stream = io.BytesIO(b"data")
442 file = UploadFile(filename="file", file=stream)
443 assert await file.read() == b"data"
444 assert file.size is None
445 await file.write(b" and more data!")
446 assert await file.read() == b""
447 assert file.size is None
448 await file.seek(0)
449 assert await file.read() == b"data and more data!"
450
451
452@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