def hello():
return "Hello World!"
-with httpx.Client(app=app) as client:
- r = client.get('http://example/')
+with httpx.Client(app=app, base_url="http://testserver") as client:
+ r = client.get("/")
assert r.status_code == 200
assert r.text == "Hello World!"
```
```python
# Instantiate a client that makes WSGI requests with a client IP of "1.2.3.4".
dispatch = httpx.WSGIDispatch(app=app, remote_addr="1.2.3.4")
-with httpx.Client(dispatch=dispatch) as client:
+with httpx.Client(dispatch=dispatch, base_url="http://testserver") as client:
...
```
```python
>>> import httpx
->>> async with httpx.AsyncClient(app=app) as client:
-... r = await client.get('http://example/')
+>>> async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+... r = await client.get("/")
... assert r.status_code == 200
... assert r.text == "Hello World!"
```
# Instantiate a client that makes ASGI requests with a client IP of "1.2.3.4",
# on port 123.
dispatch = httpx.ASGIDispatch(app=app, client=("1.2.3.4", 123))
-async with httpx.AsyncClient(dispatch=dispatch) as client:
+async with httpx.AsyncClient(dispatch=dispatch, base_url="http://testserver") as client:
...
```