Hello community, here is the log from the commit of package python-responses for openSUSE:Factory checked in at 2018-07-10 16:16:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-responses (Old) and /work/SRC/openSUSE:Factory/.python-responses.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-responses" Tue Jul 10 16:16:37 2018 rev:4 rq:621746 version:0.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-responses/python-responses.changes 2018-03-11 15:24:06.381679687 +0100 +++ /work/SRC/openSUSE:Factory/.python-responses.new/python-responses.changes 2018-07-10 16:16:59.753390703 +0200 @@ -1,0 +2,10 @@ +Mon Jul 9 15:49:05 UTC 2018 - [email protected] + +- Update to 0.9.0 + + Support for Python 3.7 + + Support streaming responses for BaseResponse + + Support custom patch targets for mock + + Fix unicode support for passthru urls + + Fix support for unicode in domain names and tlds + +------------------------------------------------------------------- Old: ---- responses-0.8.1.tar.gz New: ---- responses-0.9.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-responses.spec ++++++ --- /var/tmp/diff_new_pack.Z9Ycqu/_old 2018-07-10 16:17:00.809389069 +0200 +++ /var/tmp/diff_new_pack.Z9Ycqu/_new 2018-07-10 16:17:00.813389063 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-responses -Version: 0.8.1 +Version: 0.9.0 Release: 0 Summary: A utility library for mocking out the `requests` Python library License: Apache-2.0 ++++++ responses-0.8.1.tar.gz -> responses-0.9.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/CHANGES new/responses-0.9.0/CHANGES --- old/responses-0.8.1/CHANGES 2017-10-02 19:00:51.000000000 +0200 +++ new/responses-0.9.0/CHANGES 2018-04-04 18:25:37.000000000 +0200 @@ -1,7 +1,11 @@ -0.8.1 +0.9.0 ----- -- Maintain 'method' param on 'add' +- Support for Python 3.7 (#196) +- Support streaming responses for BaseResponse (#192) +- Support custom patch targets for mock (#189) +- Fix unicode support for passthru urls (#178) +- Fix support for unicode in domain names and tlds (177) 0.8.0 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/PKG-INFO new/responses-0.9.0/PKG-INFO --- old/responses-0.8.1/PKG-INFO 2017-10-02 19:02:17.000000000 +0200 +++ new/responses-0.9.0/PKG-INFO 2018-04-04 18:59:20.000000000 +0200 @@ -1,10 +1,9 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: responses -Version: 0.8.1 +Version: 0.9.0 Summary: A utility library for mocking out the `requests` Python library. Home-page: https://github.com/getsentry/responses Author: David Cramer -Author-email: UNKNOWN License: Apache 2.0 Description: Responses ========= @@ -16,6 +15,10 @@ .. note:: Responses requires Python 2.7 or newer, and requests >= 2.0 + Installing + ---------- + ``pip install responses`` + Basics ------ @@ -24,6 +27,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): @@ -44,6 +48,7 @@ .. code-block:: python import responses + import requests from requests.exceptions import ConnectionError @@ -57,6 +62,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): @@ -276,3 +282,4 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development +Provides-Extra: tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/README.rst new/responses-0.9.0/README.rst --- old/responses-0.8.1/README.rst 2017-09-26 23:58:49.000000000 +0200 +++ new/responses-0.9.0/README.rst 2018-04-04 17:47:12.000000000 +0200 @@ -8,6 +8,10 @@ .. note:: Responses requires Python 2.7 or newer, and requests >= 2.0 +Installing +---------- +``pip install responses`` + Basics ------ @@ -16,6 +20,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): @@ -36,6 +41,7 @@ .. code-block:: python import responses + import requests from requests.exceptions import ConnectionError @@ -49,6 +55,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/responses.egg-info/PKG-INFO new/responses-0.9.0/responses.egg-info/PKG-INFO --- old/responses-0.8.1/responses.egg-info/PKG-INFO 2017-10-02 19:02:17.000000000 +0200 +++ new/responses-0.9.0/responses.egg-info/PKG-INFO 2018-04-04 18:59:20.000000000 +0200 @@ -1,10 +1,9 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: responses -Version: 0.8.1 +Version: 0.9.0 Summary: A utility library for mocking out the `requests` Python library. Home-page: https://github.com/getsentry/responses Author: David Cramer -Author-email: UNKNOWN License: Apache 2.0 Description: Responses ========= @@ -16,6 +15,10 @@ .. note:: Responses requires Python 2.7 or newer, and requests >= 2.0 + Installing + ---------- + ``pip install responses`` + Basics ------ @@ -24,6 +27,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): @@ -44,6 +48,7 @@ .. code-block:: python import responses + import requests from requests.exceptions import ConnectionError @@ -57,6 +62,7 @@ .. code-block:: python import responses + import requests @responses.activate def test_simple(): @@ -276,3 +282,4 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development +Provides-Extra: tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/responses.py new/responses-0.9.0/responses.py --- old/responses-0.8.1/responses.py 2017-10-02 19:00:38.000000000 +0200 +++ new/responses-0.9.0/responses.py 2018-04-04 18:22:34.000000000 +0200 @@ -23,8 +23,9 @@ if six.PY2: from urlparse import urlparse, parse_qsl, urlsplit, urlunsplit + from urllib import quote else: - from urllib.parse import urlparse, parse_qsl, urlsplit, urlunsplit + from urllib.parse import urlparse, parse_qsl, urlsplit, urlunsplit, quote if six.PY2: try: @@ -34,6 +35,17 @@ else: from io import BytesIO as BufferIO +try: + from unittest import mock as std_mock +except ImportError: + import mock as std_mock + +try: + Pattern = re._pattern_type +except AttributeError: + # Python 3.7 + Pattern = re.Pattern + UNSET = object() Call = namedtuple('Call', ['request', 'response']) @@ -53,6 +65,34 @@ return isinstance(s, six.string_types) +def _has_unicode(s): + return any(ord(char) > 128 for char in s) + + +def _clean_unicode(url): + # Clean up domain names, which use punycode to handle unicode chars + urllist = list(urlsplit(url)) + netloc = urllist[1] + if _has_unicode(netloc): + domains = netloc.split('.') + for i, d in enumerate(domains): + if _has_unicode(d): + d = 'xn--' + d.encode('punycode').decode('ascii') + domains[i] = d + urllist[1] = '.'.join(domains) + url = urlunsplit(urllist) + + # Clean up path/query/params, which use url-encoding to handle unicode chars + if isinstance(url.encode('utf8'), six.string_types): + url = url.encode('utf8') + chars = list(url) + for i, x in enumerate(chars): + if ord(x) > 128: + chars[i] = quote(x) + + return ''.join(chars) + + def _is_redirect(response): try: # 2.0.0 <= requests <= 2.2 @@ -132,6 +172,8 @@ content_type = None headers = None + stream = False + def __init__(self, method, url, match_querystring=False): self.method = method self.match_querystring = match_querystring @@ -149,10 +191,10 @@ # Can't simply do a equality check on the objects directly here since __eq__ isn't # implemented for regex. It might seem to work as regex is using a cache to return # the same regex instances, but it doesn't in all cases. - self_url = self.url.pattern if isinstance( - self.url, re._pattern_type) else self.url - other_url = other.url.pattern if isinstance( - other.url, re._pattern_type) else other.url + self_url = self.url.pattern if isinstance(self.url, + Pattern) else self.url + other_url = other.url.pattern if isinstance(other.url, + Pattern) else other.url return self_url == other_url @@ -173,29 +215,25 @@ return False for (a_k, a_v), (b_k, b_v) in zip(url_qsl, other_qsl): - if not isinstance(a_k, six.text_type): - a_k = a_k.decode('utf-8') - if not isinstance(b_k, six.text_type): - b_k = b_k.decode('utf-8') if a_k != b_k: return False - if not isinstance(a_v, six.text_type): - a_v = a_v.decode('utf-8') - if not isinstance(b_v, six.text_type): - b_v = b_v.decode('utf-8') if a_v != b_v: return False return True def _url_matches(self, url, other, match_querystring=False): if _is_string(url): + if _has_unicode(url): + url = _clean_unicode(url) + if not isinstance(other, six.text_type): + other = other.encode('ascii').decode('utf8') if match_querystring: return self._url_matches_strict(url, other) else: url_without_qs = url.split('?', 1)[0] other_without_qs = other.split('?', 1)[0] return url_without_qs == other_without_qs - elif isinstance(url, re._pattern_type) and url.match(other): + elif isinstance(url, Pattern) and url.match(other): return True else: return False @@ -316,12 +354,14 @@ def __init__(self, assert_all_requests_are_fired=True, response_callback=None, - passthru_prefixes=()): + passthru_prefixes=(), + target='requests.adapters.HTTPAdapter.send'): self._calls = CallList() self.reset() self.assert_all_requests_are_fired = assert_all_requests_are_fired self.response_callback = response_callback self.passthru_prefixes = tuple(passthru_prefixes) + self.target = target def reset(self): self._matches = [] @@ -389,6 +429,8 @@ >>> responses.add_passthru('https://example.com') """ + if _has_unicode(prefix): + prefix = _clean_unicode(prefix) self.passthru_prefixes += (prefix, ) def remove(self, method_or_response=None, url=None): @@ -526,16 +568,10 @@ return response def start(self): - try: - from unittest import mock - except ImportError: - import mock - def unbound_on_send(adapter, request, *a, **kwargs): return self._on_request(adapter, request, *a, **kwargs) - self._patcher = mock.patch('requests.adapters.HTTPAdapter.send', - unbound_on_send) + self._patcher = std_mock.patch(target=self.target, new=unbound_on_send) self._patcher.start() def stop(self, allow_assert=True): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/setup.py new/responses-0.9.0/setup.py --- old/responses-0.8.1/setup.py 2017-10-02 19:01:17.000000000 +0200 +++ new/responses-0.9.0/setup.py 2018-04-04 18:27:26.000000000 +0200 @@ -24,7 +24,7 @@ install_requires = [ 'requests>=2.0', 'cookies', - 'six', + 'six' ] tests_require = [ @@ -69,7 +69,7 @@ setup( name='responses', - version='0.8.1', + version='0.9.0', author='David Cramer', description=( 'A utility library for mocking out the `requests` Python library.'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/responses-0.8.1/test_responses.py new/responses-0.9.0/test_responses.py --- old/responses-0.8.1/test_responses.py 2017-10-02 19:00:38.000000000 +0200 +++ new/responses-0.9.0/test_responses.py 2018-04-04 17:47:12.000000000 +0200 @@ -648,7 +648,7 @@ assert_reset() -def test_handles_chinese_url(): +def test_handles_unicode_querystring(): url = u'http://example.com/test?type=2&ie=utf8&query=汉字' @responses.activate @@ -663,6 +663,21 @@ assert_reset() +def test_handles_unicode_url(): + url = u'http://www.संजाल.भारत/hi/वेबसाइट-डिजाइन' + + @responses.activate + def run(): + responses.add(responses.GET, url, body='test') + + resp = requests.get(url) + + assert_response(resp, 'test') + + run() + assert_reset() + + def test_headers(): @responses.activate def run(): @@ -761,3 +776,26 @@ run() assert_reset() + + +def test_passthru_unicode(): + @responses.activate + def run(): + with responses.RequestsMock() as m: + url = u'http://موقع.وزارة-الاتصالات.مصر/' + clean_url = 'http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/' + m.add_passthru(url) + assert m.passthru_prefixes[0] == clean_url + + run() + assert_reset() + + +def test_custom_target(monkeypatch): + requests_mock = responses.RequestsMock(target='something.else') + std_mock_mock = responses.std_mock.MagicMock() + patch_mock = std_mock_mock.patch + monkeypatch.setattr(responses, 'std_mock', std_mock_mock) + requests_mock.start() + assert len(patch_mock.call_args_list) == 1 + assert patch_mock.call_args[1]['target'] == 'something.else'
