Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data pattern matching for lists broken between 0.20.2 and 0.21.1 #263

Open
alex-young opened this issue Apr 1, 2024 · 4 comments · May be fixed by #264
Open

Data pattern matching for lists broken between 0.20.2 and 0.21.1 #263

alex-young opened this issue Apr 1, 2024 · 4 comments · May be fixed by #264

Comments

@alex-young
Copy link

Using httpx==0.25.1

Test case:

def test_respx_data_list():
    with respx.mock:
        respx.post("http://example.com", data={"foo": ["bar"]})
        httpx.post("http://example.com", data={"foo": ["bar"]})

In 0.20.2 this test passes as expected. In 0.21.1 it fails with a AllMockedAssertionError

@lundberg
Copy link
Owner

lundberg commented Apr 2, 2024

You're right, this looks like a bug .. looking in to it

@lundberg lundberg linked a pull request Apr 2, 2024 that will close this issue
@lundberg
Copy link
Owner

lundberg commented Apr 2, 2024

@alex-young please try #264 with your code, if possible. Thanks.

@alex-young
Copy link
Author

@lundberg I tested #264 and it works with our tests.
Thanks for fixing so quickly!

@gpsa
Copy link

gpsa commented Aug 13, 2024

I dunno if this is related, but there's another issue with Data pattern matching.

If you add a boolean value to data={"someboolean": True}, it doesn't match the given mock.

Steps to reproduce:

import httpx
import pytest


@pytest.mark.respx(assert_all_called=True, assert_all_mocked=True)
def test_respx_httpx_bug(
    respx_mock,
) -> None:
    respx_mock.post(
        "https://domain.com/test",
        data={
            "customer": "1",
            "boolean_value": True,
        },
    ).mock(return_value=httpx.Response(200, json={"id": "123456"}))

    response = httpx.post(
        "https://domain.com/test",
        data={
            "customer": "1",
            "boolean_value": True,
        },
    )

I noticed httpx gets properly that converted into urlencoded like: boolean_value=true, whereas respx converts that to boolean_value=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants