-
Notifications
You must be signed in to change notification settings - Fork 71
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
Passing Parameters In URLs #225
Comments
What isn't supported at the moment for this to work? Because of where requests-mock sits in the chain there's generally nothing we need to do to support configuration like this, requests/urllib will turn it into a http request for us. I then normally just give some helpers to make matching easier. In this case import requests
import requests_mock
with requests_mock.Mocker() as m:
url = 'https://httpbin.org/get'
m.get(
url=url,
status_code=200,
text='hello',
)
payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
r = requests.get(url, params=payload)
print("requests url", r.url)
print("req-mock url", m.last_request.url)
print("")
print("requests payload", payload)
print("req-mock payload", m.last_request.qs)
you can see the |
Thanks for the reply! I should have been more specific about my request, sorry about that.
I apologize if I'm totally wrong here and just doing something dumb. I'm new to Python :) |
ah, i see. the functionality is there i just don't use the https://requests-mock.readthedocs.io/en/stable/matching.html#query-strings |
One conceptually nice thing about a |
Requests allows you to pass the url parameters in as a dictionary of strings (From their docs)
Would be really nice to have this in requests-mock so that tests can be 1:1
The text was updated successfully, but these errors were encountered: