see https://github.com/Kludex/starlette/pull/935
(tmpdir: Path, test_client_factory: TestClientFactory)
| 44 | |
| 45 | |
| 46 | def test_staticfiles_head_with_middleware(tmpdir: Path, test_client_factory: TestClientFactory) -> None: |
| 47 | """ |
| 48 | see https://github.com/Kludex/starlette/pull/935 |
| 49 | """ |
| 50 | path = os.path.join(tmpdir, "example.txt") |
| 51 | with open(path, "w") as file: |
| 52 | file.write("x" * 100) |
| 53 | |
| 54 | async def does_nothing_middleware(request: Request, call_next: RequestResponseEndpoint) -> Response: |
| 55 | response = await call_next(request) |
| 56 | return response |
| 57 | |
| 58 | routes = [Mount("/static", app=StaticFiles(directory=tmpdir), name="static")] |
| 59 | middleware = [Middleware(BaseHTTPMiddleware, dispatch=does_nothing_middleware)] |
| 60 | app = Starlette(routes=routes, middleware=middleware) |
| 61 | |
| 62 | client = test_client_factory(app) |
| 63 | response = client.head("/static/example.txt") |
| 64 | assert response.status_code == 200 |
| 65 | assert response.headers.get("content-length") == "100" |
| 66 | |
| 67 | |
| 68 | def test_staticfiles_with_package(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected