TestClient doesn't merge urls in the same way as the httpx client, and I think it should. #2300
Replies: 1 comment
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The TestClient just delegates the url merging to the join method of the httpx.URL object.
This causes the base path configuration to be ignored in some cases.
eg.
This how the merge is done in the Starlette TestClient's request() method.
It creates unintuitive behaviour in the following example (which i think is a common way to use the test client)
the way that httpx performs this merge is via the following code (i've lifted it straight from the httpx source code):
Starlette should be doing this the same way.
Beta Was this translation helpful? Give feedback.
All reactions