test_list_bytes_file_preserves_order() — fastapi Function Reference
Architecture documentation for the test_list_bytes_file_preserves_order() function in test_list_bytes_file_order_preserved_issue_14811.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 0a0783d5_c13a_5b90_56bd_ea672d83efb9["test_list_bytes_file_preserves_order()"] 912ec46b_b44d_d220_086e_32e97ac7092e["test_list_bytes_file_order_preserved_issue_14811.py"] 0a0783d5_c13a_5b90_56bd_ea672d83efb9 -->|defined in| 912ec46b_b44d_d220_086e_32e97ac7092e style 0a0783d5_c13a_5b90_56bd_ea672d83efb9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_list_bytes_file_order_preserved_issue_14811.py lines 16–46
def test_list_bytes_file_preserves_order(
monkeypatch: pytest.MonkeyPatch,
) -> None:
app = FastAPI()
@app.post("/upload")
async def upload(files: Annotated[list[bytes], File()]):
# return something that makes order obvious
return [b[0] for b in files]
original_read = StarletteUploadFile.read
async def patched_read(self: StarletteUploadFile, size: int = -1) -> bytes:
# Make the FIRST file slower *deterministically*
if self.filename == "slow.txt":
await anyio.sleep(0.05)
return await original_read(self, size)
monkeypatch.setattr(StarletteUploadFile, "read", patched_read)
client = TestClient(app)
files = [
("files", ("slow.txt", b"A" * 10, "text/plain")),
("files", ("fast.txt", b"B" * 10, "text/plain")),
]
r = client.post("/upload", files=files)
assert r.status_code == 200, r.text
# Must preserve request order: slow first, fast second
assert r.json() == [ord("A"), ord("B")]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_list_bytes_file_preserves_order() do?
test_list_bytes_file_preserves_order() is a function in the fastapi codebase, defined in tests/test_list_bytes_file_order_preserved_issue_14811.py.
Where is test_list_bytes_file_preserves_order() defined?
test_list_bytes_file_preserves_order() is defined in tests/test_list_bytes_file_order_preserved_issue_14811.py at line 16.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free