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

Function test_app_mount

tests/test_applications.py:316–335  ·  view source on GitHub ↗
(tmpdir: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

314
315
316def test_app_mount(tmpdir: Path, test_client_factory: TestClientFactory) -> None:
317 path = os.path.join(tmpdir, "example.txt")
318 with open(path, "w") as file:
319 file.write("<file content>")
320
321 app = Starlette(
322 routes=[
323 Mount("/static", StaticFiles(directory=tmpdir)),
324 ]
325 )
326
327 client = test_client_factory(app)
328
329 response = client.get("/static/example.txt")
330 assert response.status_code == 200
331 assert response.text == "<file content>"
332
333 response = client.post("/static/example.txt")
334 assert response.status_code == 405
335 assert response.text == "Method Not Allowed"
336
337
338def test_app_debug(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 7

StarletteClass · 0.90
MountClass · 0.90
StaticFilesClass · 0.90
test_client_factoryFunction · 0.85
writeMethod · 0.45
getMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected