-
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
Mocker doesn't urllib.parse.quote() URLs (requests does) #158
Comments
I don't think it's intentional, if it works for requests it should work here too. Will try and have a look this week, but if you want to PR it please go ahead. |
Requests-mock safely quotes things like spaces and non-url safe characters. We should do the same thing so that the matchers work. Fix tests that were passing even though they had invalid schema and shouldn't have been working. Closes: #158
Requests-mock safely quotes things like spaces and non-url safe characters. We should do the same thing so that the matchers work. Fix tests that were passing even though they had invalid schema and shouldn't have been working. Closes: #158
released as 1.9.0 |
IMO this was a breaking change. Everyone was encoding their paths already, and now they all fail to match. requests_mock.get('http://test/ABC%20123')
|
I used to register my URLs like so (with requests-mock 1.8.0): adapter.register_uri(
'GET',
'https://example.com/api/v1/user/coolmanager@example.com',
json={'id': 123456}) Unfortunately those are registered as encoded now, so they no longer match. I stepped through my tests with pytest's
|
Requests uses a slightly different quoting mechanism that quotes spaces, but not other characters.
Can we revert the current change for now? I've pushed #167 |
This broke all our tests too. However, not sure that reverting this is the way to got, but at least the behavior should be identical to requests. |
The previous fix to jamielennox#158 didn't match requests' own behavior and quoted a lot of additional characters, causing test breakage. Use `requests.utils.requote_uri` to quote the URL instead, which should ensure the behavior matches requests more closely.
Ah - this is in hindsight an obvious break. Very sorry. Tracking the issue as #170, i'll tag you all but please comment there. |
Everything in the title - I have an URL with a space in it, it's
urllib.parse.quote()
-ed to%20
by requests but not by requests-mock, resulting in a failed match!Thanks in advance :-) I could PR this, but I'm first wondering if that's maybe intentional...?
EDIT: (it's quote() not urlencode() haha)
The text was updated successfully, but these errors were encountered: