MCPcopy Create free account
hub / github.com/encode/starlette / test_custom_on_error

Function test_custom_on_error

tests/test_authentication.py:348–356  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

346
347
348def test_custom_on_error(test_client_factory: TestClientFactory) -> None:
349 with test_client_factory(other_app) as client:
350 response = client.get("/control-panel", auth=("tomchristie", "example"))
351 assert response.status_code == 200
352 assert response.json() == {"authenticated": True, "user": "tomchristie"}
353
354 response = client.get("/control-panel", headers={"Authorization": "basic foobar"})
355 assert response.status_code == 401
356 assert response.json() == {"error": "Invalid basic auth credentials"}

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected