-
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
Query string on the request object wrapper is erroneously empty #221
Comments
It seems like a bug. Can you write it as a test case? |
So i can't reproduce the value not being present. Compared to your test case the qs is a list, because you can specify the same qs multiple times, and it's always a string but the value is definitely present.
If i change your test case to |
I came across the same issue, and it seems like the used # request_mock.mock() and http-schema works
def test_requests_mock():
with requests_mock.mock() as m:
url = "http://www.example.com"
m.get(url=f"{url}/path", text="abc")
resp = requests.get(url=f"{url}/path", params={"limit": 10})
assert m.last_request.qs["limit"] == ["10"]
# request_mock.Mocker() and http-schema works
def test_requests_mocker():
with requests_mock.Mocker() as m:
url = "http://www.example.com"
m.get(url=f"{url}/path", text="abc")
resp = requests.get(url=f"{url}/path", params={"limit": 10})
assert m.last_request.qs["limit"] == ["10"]
# requests_mock.Mocker() and mock-schema doesn't work
def test_requests_mocker_mock_schema():
with requests_mock.Mocker() as m:
url = "mock://www.example.com"
m.get(url=f"{url}/path", text="abc")
resp = requests.get(url=f"{url}/path", params={"limit": 10})
assert m.last_request.qs["limit"] == ["10"] Thanks for your response @jamielennox, this helped me find out what the issue was for me. |
That's interesting, it means requests is parsing qs differently based on the scheme of the URL? It's definitely not something we're handling in requests-mock.
|
I'm trying to test out some pretty simple pagination, so I'm making a request using the following syntax:
and catching it using something like:
The request gets intercepted, but the
mocker.last_request.qs
attribute is empty. I was hoping it would hold{'limit': 10}
. Is this a bug, or is there another way to get the query string from this request?The text was updated successfully, but these errors were encountered: