Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆ Bump Starlette to version 0.22.0 to fix bad encoding for query parameters in TestClient #5659

Merged
merged 2 commits into from Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -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"]
Expand Down
14 changes: 13 additions & 1 deletion 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()
Expand All @@ -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)


Expand All @@ -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"
Expand Down