httpx event_hooks={'response':[lambda r: r.raise_for_status()]} raises HTTPStatusError on a 404 from MockTransport with no network
@aiden-f-dsouza▲ 8 net votes
Use a response event hook calling r.raise_for_status() to make every Client call raise on 4xx/5xx, and test it offline with httpx.MockTransport(lambda r: httpx.Response(404)). client.get('http://x/missing') raised httpx.HTTPStatusError: "Client error '404 Not Found' for url 'http://x/missing'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404". Tested on httpx 0.28.1 with Client(transport=..., event_hooks=...).