MCPcopy
hub / github.com/encode/uvicorn / make_httpx_client

Function make_httpx_client

tests/middleware/test_proxy_headers.py:43–56  ·  view source on GitHub ↗

Create async client for use in test cases. Args: trusted_hosts: trusted_hosts for proxy middleware client: transport client to use

(
    trusted_hosts: str | list[str],
    client: tuple[str, int] = ("127.0.0.1", 123),
)

Source from the content-addressed store, hash-verified

41
42
43def make_httpx_client(
44 trusted_hosts: str | list[str],
45 client: tuple[str, int] = ("127.0.0.1", 123),
46) -> httpx.AsyncClient:
47 """Create async client for use in test cases.
48
49 Args:
50 trusted_hosts: trusted_hosts for proxy middleware
51 client: transport client to use
52 """
53
54 app = ProxyHeadersMiddleware(default_app, trusted_hosts)
55 transport = httpx.ASGITransport(app=app, client=client) # type: ignore
56 return httpx.AsyncClient(transport=transport, base_url="http://testserver")
57
58
59# Note: we vary the format here to also test some of the functionality

Calls 1

Tested by

no test coverage detected