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

Function test_exception_on_mounted_apps

tests/test_routing.py:921–933  ·  view source on GitHub ↗
(
    test_client_factory: TestClientFactory,
)

Source from the content-addressed store, hash-verified

919
920
921def test_exception_on_mounted_apps(
922 test_client_factory: TestClientFactory,
923) -> None:
924 def exc(request: Request) -> None:
925 raise Exception("Exc")
926
927 sub_app = Starlette(routes=[Route("/", exc)])
928 app = Starlette(routes=[Mount("/sub", app=sub_app)])
929
930 client = test_client_factory(app)
931 with pytest.raises(Exception) as ctx:
932 client.get("/sub/")
933 assert str(ctx.value) == "Exc"
934
935
936def test_mounted_middleware_does_not_catch_exception(

Callers

nothing calls this directly

Calls 5

StarletteClass · 0.90
RouteClass · 0.90
MountClass · 0.90
test_client_factoryFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected