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

Function test_file_response_with_chinese_filename

tests/test_responses.py:322–333  ·  view source on GitHub ↗
(tmp_path: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

320
321
322def test_file_response_with_chinese_filename(tmp_path: Path, test_client_factory: TestClientFactory) -> None:
323 content = b"file content"
324 filename = "你好.txt" # probably "Hello.txt" in Chinese
325 path = tmp_path / filename
326 path.write_bytes(content)
327 app = FileResponse(path=path, filename=filename)
328 client = test_client_factory(app)
329 response = client.get("/")
330 expected_disposition = "attachment; filename*=utf-8''%E4%BD%A0%E5%A5%BD.txt"
331 assert response.status_code == status.HTTP_200_OK
332 assert response.content == content
333 assert response.headers["content-disposition"] == expected_disposition
334
335
336def test_file_response_with_inline_disposition(tmp_path: Path, test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

FileResponseClass · 0.90
test_client_factoryFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected