MCPcopy
hub / github.com/encode/starlette / test_staticfiles_with_pathlib

Function test_staticfiles_with_pathlib

tests/test_staticfiles.py:34–43  ·  view source on GitHub ↗
(tmp_path: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

32
33
34def test_staticfiles_with_pathlib(tmp_path: Path, test_client_factory: TestClientFactory) -> None:
35 path = tmp_path / "example.txt"
36 with open(path, "w") as file:
37 file.write("<file content>")
38
39 app = StaticFiles(directory=tmp_path)
40 client = test_client_factory(app)
41 response = client.get("/example.txt")
42 assert response.status_code == 200
43 assert response.text == "<file content>"
44
45
46def test_staticfiles_head_with_middleware(tmpdir: Path, test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

StaticFilesClass · 0.90
test_client_factoryFunction · 0.85
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected