From: William David Edwards Date: Sun, 16 Feb 2025 10:44:10 +0000 (+0100) Subject: Use `localhost` instead of `http://localhost` in `TestClient(client=...)` example... X-Git-Tag: 0.46.0~11 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=16959423f1aeb48910f57d359782577f02647b29;p=thirdparty%2Fstarlette.git Use `localhost` instead of `http://localhost` in `TestClient(client=...)` example (#2870) With https://github.com/encode/starlette/pull/2810, it is possible to override the client host (i.e. the remote address; see https://www.starlette.io/requests/#client-address). The default value for `TestClient` is `testclient`, but an IP address in most circumstances. The documentation example for overriding the client host uses a full URI, which makes no sense: it's the remote address. --- diff --git a/docs/testclient.md b/docs/testclient.md index ab05c429..b5e3b5b8 100644 --- a/docs/testclient.md +++ b/docs/testclient.md @@ -86,7 +86,7 @@ By default, the TestClient will set the client host to `"testserver"` and the po You can change the client address by setting the `client` attribute of the `TestClient` instance: ```python -client = TestClient(app, client=('http://localhost', 8000)) +client = TestClient(app, client=('localhost', 8000)) ``` ### Selecting the Async backend