respx
respx copied to clipboard
Consider a router option to define default response
As discussed in https://github.com/lundberg/respx/issues/177#issuecomment-1399321666 .
By default, respx responds with a httpx.Resopnse(200) when no mocked route is matched and assert_all_mocked is disabled.
The idea is to allow the router to take a default mock option to override that.
e.g.
mock_api = respx.mock(base_url="https://example.com/", default_mock=httpx.Response(404))
@mock_api
def test_example():
response = httpx.get("https://example.com/some/path/")
assert response.status_code == 404
By setting this option, assert_all_mocked should probably be forced disabled.