MCPcopy
hub / github.com/fastapi/fastapi / test_basic_file_serving

Function test_basic_file_serving

tests/test_frontend.py:256–267  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

254
255
256def test_basic_file_serving(tmp_path: Path):
257 dist = tmp_path / "dist"
258 write_file(dist / "assets" / "app.js", "console.log('ok')")
259 app = FastAPI()
260 app.frontend("/", directory=dist)
261
262 response = TestClient(app).get("/assets/app.js")
263
264 assert response.status_code == 200
265 assert response.text == "console.log('ok')"
266 assert "etag" in response.headers
267 assert "last-modified" in response.headers
268
269
270def test_app_frontend_dependencies_protect_root_asset_and_fallback(tmp_path: Path):

Callers

nothing calls this directly

Calls 4

frontendMethod · 0.95
FastAPIClass · 0.90
write_fileFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…