* ♻️ Do not use the deprecated `method` parameter in `FileResponse` inside of` StaticFile`
* ✅ Add test for warning FileResponse with method argument
* 🔊 Remove warning filter for FileResponse with method
"ignore: The `allow_redirects` argument is deprecated. Use `follow_redirects` instead.:DeprecationWarning",
"ignore: 'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning",
"ignore: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.:RuntimeWarning",
- "ignore: The 'method' parameter is not used, and it will be removed.:DeprecationWarning:starlette",
]
[tool.coverage.run]
scope: Scope,
status_code: int = 200,
) -> Response:
- method = scope["method"]
request_headers = Headers(scope=scope)
response = FileResponse(
- full_path, status_code=status_code, stat_result=stat_result, method=method
+ full_path, status_code=status_code, stat_result=stat_result
)
if self.is_not_modified(response.headers, request_headers):
return NotModifiedResponse(response.headers)
assert response.headers["content-disposition"] == expected_disposition
+def test_file_response_with_method_warns(tmpdir, test_client_factory):
+ with pytest.warns(DeprecationWarning):
+ FileResponse(path=tmpdir, filename="example.png", method="GET")
+
+
def test_set_cookie(test_client_factory, monkeypatch):
# Mock time used as a reference for `Expires` by stdlib `SimpleCookie`.
mocked_now = dt.datetime(2037, 1, 22, 12, 0, 0, tzinfo=dt.timezone.utc)