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

Function test_staticfiles

tests/test_staticfiles.py:22–31  ·  view source on GitHub ↗
(tmpdir: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

20
21
22def test_staticfiles(tmpdir: Path, test_client_factory: TestClientFactory) -> None:
23 path = os.path.join(tmpdir, "example.txt")
24 with open(path, "w") as file:
25 file.write("<file content>")
26
27 app = StaticFiles(directory=tmpdir)
28 client = test_client_factory(app)
29 response = client.get("/example.txt")
30 assert response.status_code == 200
31 assert response.text == "<file content>"
32
33
34def test_staticfiles_with_pathlib(tmp_path: 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