Skip to content

Commit

Permalink
Use requests to quote URLs
Browse files Browse the repository at this point in the history
The previous fix to #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.
  • Loading branch information
Matoking committed Apr 29, 2021
1 parent cb8084a commit 9dfb42d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion requests_mock/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import weakref

from requests.adapters import BaseAdapter
from requests.utils import requote_uri
import six
from six.moves.urllib import parse as urlparse

Expand Down Expand Up @@ -102,7 +103,7 @@ def __init__(self, method, url, responses, complete_qs, request_headers,
url_parts = urlparse.urlparse(url)
self._scheme = url_parts.scheme.lower()
self._netloc = url_parts.netloc.lower()
self._path = urlparse.quote(url_parts.path or '/')
self._path = requote_uri(url_parts.path or '/')
self._query = url_parts.query

if not case_sensitive:
Expand Down

0 comments on commit 9dfb42d

Please sign in to comment.