Home / Function/ test_upload_file_is_closed() — fastapi Function Reference

test_upload_file_is_closed() — fastapi Function Reference

Architecture documentation for the test_upload_file_is_closed() function in test_datastructures.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  33fa6d74_ce60_5daf_ab8c_e2ecb7ea3282["test_upload_file_is_closed()"]
  03dbbf97_8dc4_0b91_12c2_0804fcc355cf["test_datastructures.py"]
  33fa6d74_ce60_5daf_ab8c_e2ecb7ea3282 -->|defined in| 03dbbf97_8dc4_0b91_12c2_0804fcc355cf
  style 33fa6d74_ce60_5daf_ab8c_e2ecb7ea3282 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_datastructures.py lines 29–48

def test_upload_file_is_closed(tmp_path: Path):
    path = tmp_path / "test.txt"
    path.write_bytes(b"<file content>")
    app = FastAPI()

    testing_file_store: list[UploadFile] = []

    @app.post("/uploadfile/")
    def create_upload_file(file: UploadFile):
        testing_file_store.append(file)
        return {"filename": file.filename}

    client = TestClient(app)
    with path.open("rb") as file:
        response = client.post("/uploadfile/", files={"file": file})
    assert response.status_code == 200, response.text
    assert response.json() == {"filename": "test.txt"}

    assert testing_file_store
    assert testing_file_store[0].file.closed

Domain

Subdomains

Frequently Asked Questions

What does test_upload_file_is_closed() do?
test_upload_file_is_closed() is a function in the fastapi codebase, defined in tests/test_datastructures.py.
Where is test_upload_file_is_closed() defined?
test_upload_file_is_closed() is defined in tests/test_datastructures.py at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free