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

Function test_raise_for_status

tests/client/test_async_client.py:115–127  ·  view source on GitHub ↗
(server)

Source from the content-addressed store, hash-verified

113
114@pytest.mark.anyio
115async def test_raise_for_status(server):
116 async with httpx.AsyncClient() as client:
117 for status_code in (200, 400, 404, 500, 505):
118 response = await client.request(
119 "GET", server.url.copy_with(path=f"/status/{status_code}")
120 )
121
122 if 400 <= status_code < 600:
123 with pytest.raises(httpx.HTTPStatusError) as exc_info:
124 response.raise_for_status()
125 assert exc_info.value.response == response
126 else:
127 assert response.raise_for_status() is response
128
129
130@pytest.mark.anyio

Callers

nothing calls this directly

Calls 3

raise_for_statusMethod · 0.80
requestMethod · 0.45
copy_withMethod · 0.45

Tested by

no test coverage detected