MCPcopy
hub / github.com/encode/httpx / test_custom_auth

Function test_custom_auth

tests/client/test_auth.py:222–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220
221@pytest.mark.anyio
222async def test_custom_auth() -> None:
223 url = "https://example.org/"
224 app = App()
225
226 def auth(request: httpx.Request) -> httpx.Request:
227 request.headers["Authorization"] = "Token 123"
228 return request
229
230 async with httpx.AsyncClient(transport=httpx.MockTransport(app)) as client:
231 response = await client.get(url, auth=auth)
232
233 assert response.status_code == 200
234 assert response.json() == {"auth": "Token 123"}
235
236
237def test_netrc_auth_credentials_exist() -> None:

Callers

nothing calls this directly

Calls 3

AppClass · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected