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

request_kwargs_matcher not working #601

Closed
johnnymetz opened this issue Oct 25, 2022 · 1 comment · Fixed by #611
Closed

request_kwargs_matcher not working #601

johnnymetz opened this issue Oct 25, 2022 · 1 comment · Fixed by #611
Assignees

Comments

@johnnymetz
Copy link

johnnymetz commented Oct 25, 2022

Describe the bug

I'm trying to mock a request that passes request arguments. In this case, allow_redirects=False. I'm reading the document but I can't seem to get it working: https://github.com/getsentry/responses#request-keyword-arguments-matcher

Am I doing something wrong or is this a bug?

Additional context

No response

Version of responses

0.22.0

Steps to Reproduce

import requests
import responses
from responses import matchers

@responses.activate(assert_all_requests_are_fired=True)
def test_responses(self):
    url = "https://example.com/"

    responses.get(
        url,
        match=[matchers.request_kwargs_matcher({"allow_redirects": False})],
    )

    requests.get(url, allow_redirects=False)

Expected Result

Test should pass.

Actual Result

Test fails with the following error:

E           requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn't match any registered mock.
E
E           Request:
E           - GET https://example.com/
E
E           Available matches:
E           - GET https://example.com/ Arguments don't match: {} doesn't match {allow_redirects: False}
@markstory
Copy link
Member

Unfortunately this is a limitation of responses. requests does not include allow_redirects as a property on the prepared request objects that responses has access to.

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