Skip to content

Support ignoring query param order if the same parameter is provided more than once #156

@victor-h-costa

Description

@victor-h-costa

As a question/feature request:

In some cases I usually convert an iterable to a set to avoid duplicates, like for example:

response = httpx.AsyncClient().get(
    "http://localhost:1111/videos",
    params={
        "field": list(set([1, 2, 2]))
    }
)

Which is difficult to test with pytest_httpx since the order of the query parameter field isn't known and doesn't really matter.

Is it possible to add new argument to HTTPXMock.add_response to ignore query param order if the same parameter is provided more than once?

# **Suggestion 1**
httpx_mock.add_response(
    method="GET",
    url="http://localhost:1111/videos?field=1&field=2",
    status_code=200,
    ignore_query_param_value_order=True,
)

# **Suggestion 2**
httpx_mock.add_response(
    method="GET",
    url="http://localhost:1111/videos?field=1&field=2",
    status_code=200,
    ignore_query_param_value_order=["field"],
)

Thanks

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