summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McLean <patrick.mclean@sony.com>2019-12-04 11:17:05 -0800
committerPatrick McLean <chutzpah@gentoo.org>2019-12-04 12:05:13 -0800
commit08256c5c10b528906582044f9194080daa36b053 (patch)
tree17f9a50a9b063afe81885d9669180f8746248f28 /dev-python/responses
parentsys-block/gparted: Depend on dev-util/itstool (diff)
downloadgentoo-08256c5c10b528906582044f9194080daa36b053.tar.gz
gentoo-08256c5c10b528906582044f9194080daa36b053.tar.bz2
gentoo-08256c5c10b528906582044f9194080daa36b053.zip
dev-python/responses-0.10.7: version bump, add py38, pypy{,3}
Copyright: Sony Interactive Entertainment Inc. Package-Manager: Portage-2.3.80, Repoman-2.3.19 Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'dev-python/responses')
-rw-r--r--dev-python/responses/Manifest1
-rw-r--r--dev-python/responses/files/responses-0.10.7-fix-cookies.patch150
-rw-r--r--dev-python/responses/files/responses-0.10.7-tests.patch12
-rw-r--r--dev-python/responses/responses-0.10.7.ebuild38
4 files changed, 201 insertions, 0 deletions
diff --git a/dev-python/responses/Manifest b/dev-python/responses/Manifest
index 011415904165..e0495f58a736 100644
--- a/dev-python/responses/Manifest
+++ b/dev-python/responses/Manifest
@@ -1,2 +1,3 @@
+DIST responses-0.10.7.tar.gz 22666 BLAKE2B 9f6d8ee0cc36ebb94bf6ac4284b474d30754af339f623a8a899061392321ba48a1f2d21593fb5bf2e6fac7c65ca6c252b6b7a1072e5548f91db489633aa3b686 SHA512 dcdbac1555090309b17eec1c02887eea5080321ff359afc42e6b558954caec2ab757e6009ae539e6e4d002cd06f2289d909a28ae583e6fa062a5df89c301e1ff
DIST responses-0.6.0.tar.gz 14073 BLAKE2B 27d4a4a380a9154ded1030278213c0cd87308a488199c277050fa2a0a1dad87a61086094bc35279ff9c4201d06c59613bd1b0dbd18b4d83b8321341f6f1c4bb0 SHA512 32d41be5850f0040a4f2ad82a057d6ef73f0f83f7d3c250fa223d5614470b0b8b58790667af76ecc6b0b7e8e2a0a069c46c7913e983730c968c603e2716dec0b
DIST responses-0.9.0.tar.gz 19766 BLAKE2B bd98c24d6458f33f7b8ad68edb3d0fc595a7d7b31889ff8270e1add13d537d80d67c3628ea6630674e8d49837f9d3933f680b366b4a7fab10048640a50129c48 SHA512 e5312587845cc9a3a938fa5d052ac1f04950d2eea5d83192c54affe079ee6593f3e249a24a8b43b1985c9fdc9131bfb477b93ca8a75d0386ed33cd56cc37d5ff
diff --git a/dev-python/responses/files/responses-0.10.7-fix-cookies.patch b/dev-python/responses/files/responses-0.10.7-fix-cookies.patch
new file mode 100644
index 000000000000..a744e652ea7f
--- /dev/null
+++ b/dev-python/responses/files/responses-0.10.7-fix-cookies.patch
@@ -0,0 +1,150 @@
+diff --git a/responses.py b/responses.py
+index 9c57301..83fef83 100644
+--- a/responses.py
++++ b/responses.py
+@@ -23,6 +23,10 @@
+ from requests.packages.urllib3.response import HTTPResponse
+ except ImportError:
+ from urllib3.response import HTTPResponse
++try:
++ from requests.packages.urllib3.connection import HTTPHeaderDict
++except ImportError:
++ from urllib3.connection import HTTPHeaderDict
+
+ if six.PY2:
+ from urlparse import urlparse, parse_qsl, urlsplit, urlunsplit
+@@ -309,11 +313,11 @@ def _url_matches(self, url, other, match_querystring=False):
+ return False
+
+ def get_headers(self):
+- headers = {}
++ headers = HTTPHeaderDict() # Duplicate headers are legal
+ if self.content_type is not None:
+ headers["Content-Type"] = self.content_type
+ if self.headers:
+- headers.update(self.headers)
++ headers.extend(self.headers)
+ return headers
+
+ def get_response(self, request):
+@@ -372,11 +376,20 @@ def get_response(self, request):
+ status = self.status
+ body = _handle_body(self.body)
+
++ # The requests library's cookie handling depends on the response object
++ # having an original response object with the headers as the `msg`, so
++ # we give it what it needs.
++ orig_response = HTTPResponse(
++ body=body, # required to avoid "ValueError: Unable to determine whether fp is closed."
++ msg=headers,
++ preload_content=False,
++ )
+ return HTTPResponse(
+ status=status,
+ reason=six.moves.http_client.responses.get(status),
+ body=body,
+ headers=headers,
++ original_response=orig_response,
+ preload_content=False,
+ )
+
+@@ -402,13 +415,22 @@ def get_response(self, request):
+ raise body
+
+ body = _handle_body(body)
+- headers.update(r_headers)
+-
++ headers.extend(r_headers)
++
++ # The requests library's cookie handling depends on the response object
++ # having an original response object with the headers as the `msg`, so
++ # we give it what it needs.
++ orig_response = HTTPResponse(
++ body=body, # required to avoid "ValueError: Unable to determine whether fp is closed."
++ msg=headers,
++ preload_content=False,
++ )
+ return HTTPResponse(
+ status=status,
+ reason=six.moves.http_client.responses.get(status),
+ body=body,
+ headers=headers,
++ original_response=orig_response,
+ preload_content=False,
+ )
+
+@@ -619,11 +641,6 @@ def _on_request(self, adapter, request, **kwargs):
+ if not match.stream:
+ response.content # NOQA
+
+- try:
+- response.cookies = _cookies_from_headers(response.headers)
+- except (KeyError, TypeError):
+- pass
+-
+ response = resp_callback(response) if resp_callback else response
+ match.call_count += 1
+ self._calls.add(request, response)
+diff --git a/test_responses.py b/test_responses.py
+index c2a4f01..65904de 100644
+--- a/test_responses.py
++++ b/test_responses.py
+@@ -657,8 +657,56 @@ def run():
+ assert resp.status_code == status
+ assert "session_id" in resp.cookies
+ assert resp.cookies["session_id"] == "12345"
+- assert resp.cookies["a"] == "b"
+- assert resp.cookies["c"] == "d"
++ assert set(resp.cookies.keys()) == set(["session_id"])
++
++ run()
++ assert_reset()
++
++
++def test_response_secure_cookies():
++ body = b"test callback"
++ status = 200
++ headers = {"set-cookie": "session_id=12345; a=b; c=d; secure"}
++ url = "http://example.com/"
++
++ def request_callback(request):
++ return (status, headers, body)
++
++ @responses.activate
++ def run():
++ responses.add_callback(responses.GET, url, request_callback)
++ resp = requests.get(url)
++ assert resp.text == "test callback"
++ assert resp.status_code == status
++ assert "session_id" in resp.cookies
++ assert resp.cookies["session_id"] == "12345"
++ assert set(resp.cookies.keys()) == set(["session_id"])
++
++ run()
++ assert_reset()
++
++
++def test_response_cookies_multiple():
++ body = b"test callback"
++ status = 200
++ headers = [
++ ("set-cookie", "1P_JAR=2019-12-31-23; path=/; domain=.example.com; HttpOnly"),
++ ("set-cookie", "NID=some=value; path=/; domain=.example.com; secure"),
++ ]
++ url = "http://example.com/"
++
++ def request_callback(request):
++ return (status, headers, body)
++
++ @responses.activate
++ def run():
++ responses.add_callback(responses.GET, url, request_callback)
++ resp = requests.get(url)
++ assert resp.text == "test callback"
++ assert resp.status_code == status
++ assert set(resp.cookies.keys()) == set(["1P_JAR", "NID"])
++ assert resp.cookies["1P_JAR"] == "2019-12-31-23"
++ assert resp.cookies["NID"] == "some=value"
+
+ run()
+ assert_reset()
diff --git a/dev-python/responses/files/responses-0.10.7-tests.patch b/dev-python/responses/files/responses-0.10.7-tests.patch
new file mode 100644
index 000000000000..764b22ab3af3
--- /dev/null
+++ b/dev-python/responses/files/responses-0.10.7-tests.patch
@@ -0,0 +1,12 @@
+diff --git a/test_responses.py b/test_responses.py
+index c2a4f01..2b85172 100644
+--- a/test_responses.py
++++ b/test_responses.py
+@@ -928,6 +928,7 @@ def _quote(s):
+ return responses.quote(responses._ensure_str(s))
+
+
++@pytest.mark.skipif(six.PY2, reason="Broken on python2")
+ def test_cookies_from_headers():
+ text = "こんにちは/世界"
+ quoted_text = _quote(text)
diff --git a/dev-python/responses/responses-0.10.7.ebuild b/dev-python/responses/responses-0.10.7.ebuild
new file mode 100644
index 000000000000..090bff78212c
--- /dev/null
+++ b/dev-python/responses/responses-0.10.7.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+PYTHON_COMPAT=( python{2_7,3_{5,6,7,8}} pypy{,3} )
+
+inherit distutils-r1
+
+DESCRIPTION="Utility for mocking out the Python Requests library"
+HOMEPAGE="https://github.com/getsentry/responses"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="test"
+
+RDEPEND="
+ >=dev-python/requests-2.0[${PYTHON_USEDEP}]
+ dev-python/cookies[${PYTHON_USEDEP}]
+ dev-python/mock[${PYTHON_USEDEP}]
+ dev-python/six[${PYTHON_USEDEP}]
+"
+
+DEPEND="
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ test? (
+ ${RDEPEND}
+ dev-python/pytest-localserver[${PYTHON_USEDEP}]
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}/responses-0.10.7-fix-cookies.patch"
+ "${FILESDIR}/responses-0.10.7-tests.patch"
+)
+
+distutils_enable_tests pytest