Skip to content

Commit

Permalink
fix PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Garrelou committed Aug 28, 2020
1 parent 305e5cd commit 8a40520
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 3 additions & 5 deletions requests_mock/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.

import requests


class _FakeHTTPMessage(object):

Expand All @@ -33,10 +31,10 @@ def get_all(self, name, failobj=None):


class _FakeHTTPResponse(object):

def __init__(self, headers):
self._headers = headers
self.msg = _FakeHTTPMessage(headers)

def isclosed(self):
return True
return True
14 changes: 9 additions & 5 deletions requests_mock/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ def read(self, *args, **kwargs):

def create_set_cookie_header(response, jar):
"""
:param requests.packages.urllib3.response response: the Response that will be updated with the Set-Cookie header
:param requests.cookies.RequestsCookieJar jar: a CookieJar containing all cookies to be converted in a Set-Cookie header
:param requests.packages.urllib3.response response: the Response that will
be updated with the Set-Cookie header
:param requests.cookies.RequestsCookieJar jar: a CookieJar containing all
cookies to be converted in a Set-Cookie header
"""
set_cookie_items = []
for cookie_name, cookie_value in response.cookies.items():
set_cookie_items.append(cookie_name + '=' + six.moves.urllib.parse.quote(cookie_value))

encoded = six.moves.urllib.parse.quote(cookie_value)
set_cookie_items.append(cookie_name + '=' + encoded)

set_cookie_header = "; ".join(set_cookie_items)

if set_cookie_header:
Expand Down Expand Up @@ -206,7 +209,8 @@ def create_response(request, **kwargs):
_extract_cookies(request, response, kwargs.get('cookies'))

create_set_cookie_header(response, response.cookies)
response.raw._original_response = compat._FakeHTTPResponse(response.headers)
response.raw._original_response = \
compat._FakeHTTPResponse(response.headers)

return response

Expand Down
2 changes: 1 addition & 1 deletion tests/test_session_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def test_cookie(self):
r = s.get("mock://test.site")

self.assertEquals(r.cookies.get("name"), "value")
self.assertEquals(s.cookies.get("name"), "value")
self.assertEquals(s.cookies.get("name"), "value")

0 comments on commit 8a40520

Please sign in to comment.