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

assert_call_count should be able to check urls without matching querystring #335

Closed
pmourlanne opened this issue Jul 3, 2020 · 0 comments · Fixed by #529
Closed

assert_call_count should be able to check urls without matching querystring #335

pmourlanne opened this issue Jul 3, 2020 · 0 comments · Fixed by #529
Assignees

Comments

@pmourlanne
Copy link

When adding an url in responses, querystring is not matched by default:

@responses.activate
def test_my_test():
    responses.add(responses.GET, "http://www.example.com")
    # Both these requests will be captured
    requests.get("http://www.example.com")
    requests.get("http://www.example.com?hello=world")

assert_call_count doesn't reproduce this behaviour:

@responses.activate
def test_assert_call_count_always_match_qs():
    responses.add(responses.GET, "http://www.example.com")
    requests.get("http://www.example.com")
    requests.get("http://www.example.com?hello=world")

    # One call on each url, querystring is matched by default
    responses.assert_call_count("http://www.example.com", 1) is True
    responses.assert_call_count("http://www.example.com?hello=world", 1) is True

I would like to be able to check the call count on one particular url without matching querystring, eg.:

@responses.activate
def test_assert_call_count_match_querystring():
    responses.add(responses.GET, "http://www.example.com")
    requests.get("http://www.example.com")
    requests.get("http://www.example.com?hello=world")

    responses.assert_call_count("http://www.example.com", 2, match_querystring=False) is True
    responses.assert_call_count("http://www.example.com?hello=world", 2, match_querystring=False) is 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
2 participants