From 162b36bd2b3c69b8b674915ef227bc69fb7660b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20Panadero=20Maci=C3=A1?= Date: Fri, 18 Nov 2022 14:56:04 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=AA=20Add=20test=20to=20show=20iss?= =?UTF-8?q?ue=20with=20non-ascii=20chars=20in=20query=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_starlette_urlconvertors.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_starlette_urlconvertors.py b/tests/test_starlette_urlconvertors.py index 5a980cbf6dad7..5ef1b819cda70 100644 --- a/tests/test_starlette_urlconvertors.py +++ b/tests/test_starlette_urlconvertors.py @@ -1,4 +1,4 @@ -from fastapi import FastAPI, Path +from fastapi import FastAPI, Path, Query from fastapi.testclient import TestClient app = FastAPI() @@ -19,6 +19,11 @@ def path_convertor(param: str = Path()): return {"path": param} +@app.get("/query/") +def query_convertor(param: str = Query()): + return {"query": param} + + client = TestClient(app) @@ -45,6 +50,13 @@ def test_route_converters_path(): assert response.json() == {"path": "some/example"} +def test_route_converters_query(): + # Test query conversion + response = client.get("/query", params={"param": "Qué tal!"}) + assert response.status_code == 200, response.text + assert response.json() == {"query": "Qué tal!"} + + def test_url_path_for_path_convertor(): assert ( app.url_path_for("path_convertor", param="some/example") == "/path/some/example" From d42a4177ddcf26eaaaca39d7192c434bbd5a7cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20Panadero=20Maci=C3=A1?= Date: Fri, 18 Nov 2022 14:57:04 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=A6=EF=B8=8F=20Bump=20starlette=20?= =?UTF-8?q?to=20fix=20bad=20encoding=20issue=20#5646?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9549cc47da156..0e48fd6dc3f87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP", ] dependencies = [ - "starlette==0.21.0", + "starlette==0.22.0", "pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0", ] dynamic = ["version"]