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

Function test_custom_on_error

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

Source from the content-addressed store, hash-verified

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