Skip to content

Consider a router option to define default response #227

@lundberg

Description

@lundberg

As discussed in #177 (comment) .

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions