Skip to content

Commit

Permalink
Use localhost instead of http://localhost in `TestClient(client=.…
Browse files Browse the repository at this point in the history
…..)` example (#2870)

With #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.
  • Loading branch information
WilliamDEdwards authored Feb 16, 2025
1 parent a7d0b14 commit 1695942
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/testclient.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1695942

Please sign in to comment.