(test_client_factory: TestClientFactory)
| 178 | |
| 179 | |
| 180 | def test_exception_in_middleware(test_client_factory: TestClientFactory) -> None: |
| 181 | class MiddlewareException(Exception): |
| 182 | pass |
| 183 | |
| 184 | class BrokenMiddleware: |
| 185 | def __init__(self, app: ASGIApp): |
| 186 | self.app = app |
| 187 | |
| 188 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 189 | raise MiddlewareException() |
| 190 | |
| 191 | broken_middleware = Starlette(middleware=[Middleware(BrokenMiddleware)]) |
| 192 | |
| 193 | with pytest.raises(MiddlewareException): |
| 194 | with test_client_factory(broken_middleware): |
| 195 | pass # pragma: no cover |
| 196 | |
| 197 | |
| 198 | def test_testclient_asgi2(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected