-
First Check
Commit to Help
Example Codeimport logging
from fastapi import FastAPI
app = FastAPI()
@app.get("/example")
async def _show_encoding_error(look_for: str):
return {"found": look_for}
if __name__ == '__main__':
from fastapi.testclient import TestClient
with TestClient(app) as client:
params = {"look_for": "plain text"}
resp = client.get("/example", params=params).json()
logging.warning(resp)
assert resp["found"] == "plain text"
params = {"look_for": "España"}
resp = client.get("/example", params=params).json()
logging.warning(resp)
assert resp["found"] == "España", resp["found"] DescriptionAfter the change to The example app works as expected if called from the SwaggerUI or from another python process using a plain import httpx
params = {"look_for": "España"}
with httpx.Client(base_url="http://localhost:8000/") as client:
resp = client.get("/example", params=params).json()
assert resp["found"] == "España" Operating SystemmacOS Operating System DetailsM1, running arm64 arch FastAPI Version0.87.0 Python VersionPython 3.10.5 Additional Contextstarlette-0.21 Discovered when trying to migrate the test suite for a ~big project previously using fastapi-0.85.1 + starlette-0.20.4. All minor syntax changes from old |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
I just saw this it is not related to FastAPI but to Starlette 😅, after encode/starlette#1376, and the example code above fails the same way if using the original object I'll try to ask there 👍 Not sure if closing this one, as |
Beta Was this translation helpful? Give feedback.
-
For those in a hurry, or just to quick-check that the strange broken tests you're having after the
will swap the published version with a fixed one containing encode/starlette#1953 👍 |
Beta Was this translation helpful? Give feedback.
-
This is solved in Starlette 0.22.0. |
Beta Was this translation helpful? Give feedback.
-
@Kludex What is the plan to fix it in FastAPI? Is there a PR that pulls in the Starlette 0.22.0? The Starlette 0.22.0 is already out. |
Beta Was this translation helpful? Give feedback.
-
@mezhaka , in #5659, but I'm new here 😅, so not sure about the workflow to generate patches, sorry |
Beta Was this translation helpful? Give feedback.
-
@azogue Nice, even with a test! |
Beta Was this translation helpful? Give feedback.
-
Thanks @azogue for reporting and upgrading it here! 🍰 Thanks everyone for the discussion too! ☕ This is available in FastAPI |
Beta Was this translation helpful? Give feedback.
This is solved in Starlette 0.22.0.