Hello community, here is the log from the commit of package python-aioresponses for openSUSE:Factory checked in at 2020-06-09 00:06:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-aioresponses (Old) and /work/SRC/openSUSE:Factory/.python-aioresponses.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-aioresponses" Tue Jun 9 00:06:51 2020 rev:7 rq:812531 version:0.6.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-aioresponses/python-aioresponses.changes 2020-01-17 16:08:33.100529868 +0100 +++ /work/SRC/openSUSE:Factory/.python-aioresponses.new.3606/python-aioresponses.changes 2020-06-09 00:09:12.366257461 +0200 @@ -1,0 +2,12 @@ +Mon Jun 8 09:41:48 UTC 2020 - Ondřej Súkup <mimi...@gmail.com> + +- update to 0.6.4 + * Load response cookies from headers + * BaseException handling(in Pyhton 3.8 asyncio.CancelError, + asyncio.TimeoutError are subclass of BaseException) + * exception can be as class or as object of exception(Exception or Exception()) + * Change method to GET for redirect after POST request. + * set request_info on response rather than a mock + * Avoid failure in case one of the request arguments cannot be deep copied + +------------------------------------------------------------------- Old: ---- aioresponses-0.6.2.tar.gz New: ---- aioresponses-0.6.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-aioresponses.spec ++++++ --- /var/tmp/diff_new_pack.BHHCE0/_old 2020-06-09 00:09:13.370261023 +0200 +++ /var/tmp/diff_new_pack.BHHCE0/_new 2020-06-09 00:09:13.374261037 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-aioresponses -Version: 0.6.2 +Version: 0.6.4 Release: 0 Summary: Python module for mocking out requests made by ClientSession from aiohttp License: MIT @@ -59,7 +59,8 @@ %check export LC_ALL=en_US.UTF-8 -%python_exec setup.py test +# disabled test which uses http://httpbin.org +%pytest -k "not test_pass_through_with_origin_params" %files %{python_files} %doc AUTHORS AUTHORS.rst ChangeLog README.rst ++++++ aioresponses-0.6.2.tar.gz -> aioresponses-0.6.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/.travis.yml new/aioresponses-0.6.4/.travis.yml --- old/aioresponses-0.6.2/.travis.yml 2019-11-21 23:22:36.000000000 +0100 +++ new/aioresponses-0.6.4/.travis.yml 2020-02-11 22:27:00.000000000 +0100 @@ -63,12 +63,24 @@ - python: 3.7 dist: xenial env: TOXENV=py37-aiohttp36 -# - python: 3.7 -# dist: xenial -# env: TOXENV=py36-aiohttp-master + - python: 3.8 + dist: xenial + env: TOXENV=py38-aiohttp33 + - python: 3.8 + dist: xenial + env: TOXENV=py38-aiohttp34 + - python: 3.8 + dist: xenial + env: TOXENV=py38-aiohttp35 + - python: 3.8 + dist: xenial + env: TOXENV=py38-aiohttp36 +# - python: 3.8 +# dist: xenial +# env: TOXENV=py38-aiohttp-master - - python: 3.7 + - python: 3.8 dist: xenial env: TOXENV=flake8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/AUTHORS new/aioresponses-0.6.4/AUTHORS --- old/aioresponses-0.6.2/AUTHORS 2020-01-09 19:10:35.000000000 +0100 +++ new/aioresponses-0.6.4/AUTHORS 2020-06-02 11:15:01.000000000 +0200 @@ -1,4 +1,5 @@ Alan Briolat <alan.brio...@gmail.com> +Aleksei Maslakov <lesha.masla...@gmail.com> Alexey Sveshnikov <a.sveshni...@rambler-co.ru> Alexey Sveshnikov <alexey.sveshni...@gmail.com> Allisson Azevedo <allis...@gmail.com> @@ -8,6 +9,7 @@ Bryce Drennan <git...@accounts.brycedrennan.com> Colin-b <coli...@users.noreply.github.com> Daniel Hahler <g...@thequod.de> +Hadrien David <hadrien.da...@dialogue.co> Ilaï Deutel <ilai-deu...@users.noreply.github.com> Joongi Kim <m...@daybreaker.info> Jordi Soucheiron <jo...@soucheiron.cat> @@ -20,7 +22,12 @@ Pavel Savchenko <asfalt...@gmail.com> Pawel Nuckowski <p.nuckow...@gmail.com> Rémy HUBSCHER <rhubsc...@mozilla.com> +TyVik <tyv...@gmail.com> Ulrik Johansson <ulrik.johans...@blocket.se> +Ville Skyttä <ville.sky...@iki.fi> +d-ryzhikov <d.ryzhy...@gmail.com> +iamnotaprogrammer <iamnotaprogram...@yandex.ru> +iamnotaprogrammer <issmir...@domclick.ru> pnuckowski <pnuckow...@users.noreply.github.com> pyup-bot <github-...@pyup.io> vangheem <vangh...@gmail.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/ChangeLog new/aioresponses-0.6.4/ChangeLog --- old/aioresponses-0.6.2/ChangeLog 2020-01-09 19:10:35.000000000 +0100 +++ new/aioresponses-0.6.4/ChangeLog 2020-06-02 11:15:01.000000000 +0200 @@ -1,6 +1,30 @@ CHANGES ======= +0.6.4 +----- + +* Change method to GET for redirect after POST request +* fixing - BaseException handling(in Pyhton 3.8 asyncio.CancelError, asyncio.TimeoutError are subclass of BaseException) extend exception attribute for RequestMatch - exception can be as class or as object of exception(Exception or Exception()) +* Load response cookies from headers +* changed variable names + +0.6.3 +----- + +* bump ver 0.6.3 +* fix: set request\_info on response rather than mock +* Codestyle fixes +* Add test case for tracking exception responses +* Track requests even if they result in an exception +* add test for this case +* i faced with some strange code behavior +* Avoid failure in case one of the request arguments cannot be deep copied +* Spelling fix +* Test with Python 3.8 +* tests: assert the correct ClientConnectionError +* fix: remove overly verbose Exception + 0.6.2 ----- @@ -9,6 +33,8 @@ * fix tests * Send a RuntimeError indicating that session is closed, the same way as aiohttp does * Save every received request. Even when no response is subscribed +* implement mocked redirects +* add (currently failing) test for redirect mocking 0.6.1 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/PKG-INFO new/aioresponses-0.6.4/PKG-INFO --- old/aioresponses-0.6.2/PKG-INFO 2020-01-09 19:10:50.000000000 +0100 +++ new/aioresponses-0.6.4/PKG-INFO 2020-06-02 11:15:02.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: aioresponses -Version: 0.6.2 +Version: 0.6.4 Summary: Mock out requests made by ClientSession from aiohttp package Home-page: https://github.com/pnuckowski/aioresponses Author: Pawel Nuckowski diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses/__init__.py new/aioresponses-0.6.4/aioresponses/__init__.py --- old/aioresponses-0.6.2/aioresponses/__init__.py 2019-01-21 22:02:56.000000000 +0100 +++ new/aioresponses-0.6.4/aioresponses/__init__.py 2020-02-11 22:41:24.000000000 +0100 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from .core import CallbackResult, aioresponses -__version__ = '0.4.1' +__version__ = '0.6.3' __all__ = [ 'CallbackResult', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses/__version__.py new/aioresponses-0.6.4/aioresponses/__version__.py --- old/aioresponses-0.6.2/aioresponses/__version__.py 2019-06-21 23:10:02.000000000 +0200 +++ new/aioresponses-0.6.4/aioresponses/__version__.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +0,0 @@ -# -*- coding: utf-8 -*- -import logging - -logger = logging.getLogger(__name__) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses/core.py new/aioresponses-0.6.4/aioresponses/core.py --- old/aioresponses-0.6.2/aioresponses/core.py 2020-01-09 19:07:56.000000000 +0100 +++ new/aioresponses-0.6.4/aioresponses/core.py 2020-06-02 11:12:41.000000000 +0200 @@ -7,7 +7,7 @@ from functools import wraps from typing import Callable, Dict, Tuple, Union, Optional, List # noqa from unittest.mock import Mock, patch - +import inspect from aiohttp import ( ClientConnectionError, ClientResponse, @@ -16,7 +16,7 @@ http ) from aiohttp.helpers import TimerNoop -from multidict import CIMultiDict +from multidict import CIMultiDict, CIMultiDictProxy from .compat import ( AIOHTTP_VERSION, @@ -113,6 +113,7 @@ def _build_response(self, url: 'Union[URL, str]', method: str = hdrs.METH_GET, + request_headers: Dict = None, status: int = 200, body: str = '', content_type: str = 'application/json', @@ -126,12 +127,18 @@ body = json.dumps(payload) if not isinstance(body, bytes): body = str.encode(body) + if request_headers is None: + request_headers = {} kwargs = {} if AIOHTTP_VERSION >= StrictVersion('3.1.0'): loop = Mock() loop.get_debug = Mock() loop.get_debug.return_value = True - kwargs['request_info'] = Mock() + kwargs['request_info'] = Mock( + url=url, + method=method, + headers=CIMultiDictProxy(CIMultiDict(**request_headers)), + ) kwargs['writer'] = Mock() kwargs['continue100'] = None kwargs['timer'] = TimerNoop() @@ -148,6 +155,10 @@ _headers.update(headers) raw_headers = self._build_raw_headers(_headers) resp = response_class(method, url, **kwargs) + + for hdr in _headers.getall(hdrs.SET_COOKIE, ()): + resp.cookies.load(hdr) + if AIOHTTP_VERSION >= StrictVersion('3.3.0'): # Reified attributes resp._headers = _headers @@ -163,10 +174,11 @@ return resp async def build_response( - self, url: URL, **kwargs: Dict + self, url: URL, **kwargs ) -> 'Union[ClientResponse, Exception]': - if isinstance(self.exception, Exception): + if self.exception is not None: return self.exception + if callable(self.callback): if asyncio.iscoroutinefunction(self.callback): result = await self.callback(url, **kwargs) @@ -178,6 +190,7 @@ resp = self._build_response( url=url, method=result.method, + request_headers=kwargs.get("headers"), status=result.status, body=result.body, content_type=result.content_type, @@ -299,21 +312,52 @@ callback=callback, )) + @staticmethod + def is_exception(resp_or_exc: Union[ClientResponse, Exception]) -> bool: + if inspect.isclass(resp_or_exc): + parent_classes = set(inspect.getmro(resp_or_exc)) + if {Exception, BaseException} & parent_classes: + return True + else: + if isinstance(resp_or_exc, (Exception, BaseException)): + return True + return False + async def match( - self, method: str, url: URL, **kwargs: Dict + self, method: str, url: URL, + allow_redirects: bool = True, **kwargs: Dict ) -> Optional['ClientResponse']: - for i, matcher in enumerate(self._matches): - if matcher.match(method, url): - response = await matcher.build_response(url, **kwargs) + history = [] + while True: + for i, matcher in enumerate(self._matches): + if matcher.match(method, url): + response_or_exc = await matcher.build_response( + url, allow_redirects=allow_redirects, **kwargs + ) + break + else: + return None + + if matcher.repeat is False: + del self._matches[i] + + if self.is_exception(response_or_exc): + raise response_or_exc + + if response_or_exc.status in ( + 301, 302, 303, 307, 308) and allow_redirects: + if hdrs.LOCATION not in response_or_exc.headers: + break + history.append(response_or_exc) + url = URL(response_or_exc.headers[hdrs.LOCATION]) + method = 'get' + continue + else: break - else: - return None - if matcher.repeat is False: - del self._matches[i] - if isinstance(response, Exception): - raise response - return response + response_or_exc._history = tuple(history) + + return response_or_exc async def _request_mock(self, orig_self: ClientSession, method: str, url: 'Union[URL, str]', @@ -323,19 +367,25 @@ if orig_self.closed: raise RuntimeError('Session is closed') + url_origin = url url = normalize_url(merge_params(url, kwargs.get('params'))) url_str = str(url) for prefix in self._passthrough: if url_str.startswith(prefix): return (await self.patcher.temp_original( - orig_self, method, url, *args, **kwargs + orig_self, method, url_origin, *args, **kwargs )) - response = await self.match(method, url, **kwargs) - key = (method, url) self.requests.setdefault(key, []) - self.requests[key].append(RequestCall(args, copy.deepcopy(kwargs))) + try: + kwargs_copy = copy.deepcopy(kwargs) + except TypeError: + # Handle the fact that some values cannot be deep copied + kwargs_copy = kwargs + self.requests[key].append(RequestCall(args, kwargs_copy)) + + response = await self.match(method, url, **kwargs) if response is None: raise ClientConnectionError( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses.egg-info/PKG-INFO new/aioresponses-0.6.4/aioresponses.egg-info/PKG-INFO --- old/aioresponses-0.6.2/aioresponses.egg-info/PKG-INFO 2020-01-09 19:10:35.000000000 +0100 +++ new/aioresponses-0.6.4/aioresponses.egg-info/PKG-INFO 2020-06-02 11:15:01.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: aioresponses -Version: 0.6.2 +Version: 0.6.4 Summary: Mock out requests made by ClientSession from aiohttp package Home-page: https://github.com/pnuckowski/aioresponses Author: Pawel Nuckowski diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses.egg-info/SOURCES.txt new/aioresponses-0.6.4/aioresponses.egg-info/SOURCES.txt --- old/aioresponses-0.6.2/aioresponses.egg-info/SOURCES.txt 2020-01-09 19:10:50.000000000 +0100 +++ new/aioresponses-0.6.4/aioresponses.egg-info/SOURCES.txt 2020-06-02 11:15:02.000000000 +0200 @@ -18,7 +18,6 @@ tox.ini unittest.cfg aioresponses/__init__.py -aioresponses/__version__.py aioresponses/compat.py aioresponses/core.py aioresponses.egg-info/PKG-INFO @@ -42,6 +41,4 @@ docs/usage.rst tests/__init__.py tests/test_aioresponses.py -tests/test_compat.py -tests/test_compat_pytest.py -tests/test_pytest.py \ No newline at end of file +tests/test_compat.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/aioresponses.egg-info/pbr.json new/aioresponses-0.6.4/aioresponses.egg-info/pbr.json --- old/aioresponses-0.6.2/aioresponses.egg-info/pbr.json 2020-01-09 19:10:35.000000000 +0100 +++ new/aioresponses-0.6.4/aioresponses.egg-info/pbr.json 2020-06-02 11:15:01.000000000 +0200 @@ -1 +1 @@ -{"git_version": "382b1a4", "is_release": false} \ No newline at end of file +{"git_version": "fc8f747", "is_release": false} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/tests/test_aioresponses.py new/aioresponses-0.6.4/tests/test_aioresponses.py --- old/aioresponses-0.6.2/tests/test_aioresponses.py 2020-01-09 19:07:56.000000000 +0100 +++ new/aioresponses-0.6.4/tests/test_aioresponses.py 2020-06-02 11:12:41.000000000 +0200 @@ -11,7 +11,7 @@ from asynctest import fail_on, skipIf from asynctest.case import TestCase from ddt import ddt, data - +from asyncio import CancelledError, TimeoutError try: from aiohttp.errors import ( ClientConnectionError, @@ -96,6 +96,15 @@ @aioresponses() @asyncio.coroutine + def test_returned_response_cookies(self, m): + m.get(self.url, + headers={'Set-Cookie': 'cookie=value'}) + response = yield from self.session.get(self.url) + + self.assertEqual(response.cookies['cookie'].value, 'value') + + @aioresponses() + @asyncio.coroutine def test_returned_response_raw_headers(self, m): m.get(self.url, content_type='text/html', @@ -223,11 +232,42 @@ yield from self.session.get('http://example.com/foo') @asyncio.coroutine - def test_raising_custom_error(self): + def test_raising_exception(self): with aioresponses() as aiomock: - aiomock.get(self.url, exception=HttpProcessingError(message='foo')) + url = 'http://example.com/Exception' + aiomock.get(url, exception=Exception) + with self.assertRaises(Exception): + yield from self.session.get(url) + + url = 'http://example.com/Exception_object' + aiomock.get(url, exception=Exception()) + with self.assertRaises(Exception): + yield from self.session.get(url) + + url = 'http://example.com/BaseException' + aiomock.get(url, exception=BaseException) + with self.assertRaises(BaseException): + yield from self.session.get(url) + + url = 'http://example.com/BaseException_object' + aiomock.get(url, exception=BaseException()) + with self.assertRaises(BaseException): + yield from self.session.get(url) + + url = 'http://example.com/CancelError' + aiomock.get(url, exception=CancelledError) + with self.assertRaises(CancelledError): + yield from self.session.get(url) + + url = 'http://example.com/TimeoutError' + aiomock.get(url, exception=TimeoutError) + with self.assertRaises(TimeoutError): + yield from self.session.get(url) + + url = 'http://example.com/HttpProcessingError' + aiomock.get(url, exception=HttpProcessingError(message='foo')) with self.assertRaises(HttpProcessingError): - yield from self.session.get(self.url) + yield from self.session.get(url) @asyncio.coroutine def test_multiple_requests(self): @@ -237,13 +277,19 @@ m.get(self.url, status=201) m.get(self.url, status=202) json_content_as_ref = [1] - resp = yield from self.session.get(self.url, json=json_content_as_ref) + resp = yield from self.session.get( + self.url, json=json_content_as_ref + ) self.assertEqual(resp.status, 200) json_content_as_ref[:] = [2] - resp = yield from self.session.get(self.url, json=json_content_as_ref) + resp = yield from self.session.get( + self.url, json=json_content_as_ref + ) self.assertEqual(resp.status, 201) json_content_as_ref[:] = [3] - resp = yield from self.session.get(self.url, json=json_content_as_ref) + resp = yield from self.session.get( + self.url, json=json_content_as_ref + ) self.assertEqual(resp.status, 202) key = ('GET', URL(self.url)) @@ -266,6 +312,29 @@ {'allow_redirects': True, "json": [3]}) @asyncio.coroutine + def test_request_with_non_deepcopyable_parameter(self): + def non_deep_copyable(): + """A generator does not allow deepcopy.""" + for line in ["header1,header2", "v1,v2", "v10,v20"]: + yield line + + generator_value = non_deep_copyable() + + with aioresponses() as m: + m.get(self.url, status=200) + resp = yield from self.session.get(self.url, data=generator_value) + self.assertEqual(resp.status, 200) + + key = ('GET', URL(self.url)) + self.assertIn(key, m.requests) + self.assertEqual(len(m.requests[key]), 1) + + request = m.requests[key][0] + self.assertEqual(request.args, tuple()) + self.assertEqual(request.kwargs, + {'allow_redirects': True, "data": generator_value}) + + @asyncio.coroutine def test_request_retrieval_in_case_no_response(self): with aioresponses() as m: with self.assertRaises(ClientConnectionError): @@ -311,6 +380,23 @@ self.assertEqual(api.status, 200) self.assertEqual(ext.status, 201) + @asyncio.coroutine + def test_pass_through_with_origin_params(self): + external_api = 'http://httpbin.org/get' + + @asyncio.coroutine + def doit(params): + # we have to hit actual url, + # otherwise we do not test pass through option properly + ext_rep = (yield from self.session.get(URL(external_api), params=params)) + return ext_rep + + with aioresponses(passthrough=[external_api]) as m: + params = {'foo': 'bar'} + ext = yield from doit(params=params) + self.assertEqual(ext.status, 200) + self.assertEqual(str(ext.url), 'http://httpbin.org/get?foo=bar') + @aioresponses() @asyncio.coroutine def test_custom_response_class(self, m): @@ -406,13 +492,30 @@ data = self.run_async(response.read()) assert data == body + @aioresponses() + @asyncio.coroutine + def test_exception_requests_are_tracked(self, mocked): + kwargs = {"json": [42], "allow_redirects": True} + mocked.get(self.url, exception=ValueError('oops')) + + with self.assertRaises(ValueError): + yield from self.session.get(self.url, **kwargs) + + key = ('GET', URL(self.url)) + mocked_requests = mocked.requests[key] + self.assertEqual(len(mocked_requests), 1) + + request = mocked_requests[0] + self.assertEqual(request.args, ()) + self.assertEqual(request.kwargs, kwargs) + class AIOResponsesRaiseForStatusSessionTestCase(TestCase): """Test case for sessions with raise_for_status=True. This flag, introduced in aiohttp v2.0.0, automatically calls `raise_for_status()`. - It is overriden by the `raise_for_status` argument of the request since + It is overridden by the `raise_for_status` argument of the request since aiohttp v3.4.a0. """ @@ -450,3 +553,104 @@ raise_for_status=False) self.assertEqual(response.status, 400) + + +class AIOResponseRedirectTest(TestCase): + @asyncio.coroutine + def setUp(self): + self.url = "http://10.1.1.1:8080/redirect" + self.session = ClientSession() + super().setUp() + + @asyncio.coroutine + def tearDown(self): + close_result = self.session.close() + if close_result is not None: + yield from close_result + super().tearDown() + + @aioresponses() + @asyncio.coroutine + def test_redirect_followed(self, rsps): + rsps.get( + self.url, + status=307, + headers={"Location": "https://httpbin.org"}, + ) + rsps.get("https://httpbin.org") + response = yield from self.session.get( + self.url, allow_redirects=True + ) + self.assertEqual(response.status, 200) + self.assertEqual(str(response.url), "https://httpbin.org") + self.assertEqual(len(response.history), 1) + self.assertEqual(str(response.history[0].url), self.url) + + @aioresponses() + @asyncio.coroutine + def test_post_redirect_followed(self, rsps): + rsps.post( + self.url, + status=307, + headers={"Location": "https://httpbin.org"}, + ) + rsps.get("https://httpbin.org") + response = yield from self.session.post( + self.url, allow_redirects=True + ) + self.assertEqual(response.status, 200) + self.assertEqual(str(response.url), "https://httpbin.org") + self.assertEqual(response.method, "get") + self.assertEqual(len(response.history), 1) + self.assertEqual(str(response.history[0].url), self.url) + + @aioresponses() + @asyncio.coroutine + def test_redirect_missing_mocked_match(self, rsps): + rsps.get( + self.url, + status=307, + headers={"Location": "https://httpbin.org"}, + ) + with self.assertRaises(ClientConnectionError) as cm: + yield from self.session.get( + self.url, allow_redirects=True + ) + self.assertEqual( + str(cm.exception), + 'Connection refused: GET http://10.1.1.1:8080/redirect' + ) + + @aioresponses() + @asyncio.coroutine + def test_redirect_missing_location_header(self, rsps): + rsps.get(self.url, status=307) + response = yield from self.session.get(self.url, allow_redirects=True) + self.assertEqual(str(response.url), self.url) + + @aioresponses() + @asyncio.coroutine + @skipIf(condition=AIOHTTP_VERSION < '3.1.0', + reason='aiohttp<3.1.0 does not add request info on response') + def test_request_info(self, rsps): + rsps.get(self.url, status=200) + + response = yield from self.session.get(self.url) + + request_info = response.request_info + assert str(request_info.url) == self.url + assert request_info.headers == {} + + @aioresponses() + @asyncio.coroutine + @skipIf(condition=AIOHTTP_VERSION < '3.1.0', + reason='aiohttp<3.1.0 does not add request info on response') + def test_request_info_with_original_request_headers(self, rsps): + headers = {"Authorization": "Bearer access-token"} + rsps.get(self.url, status=200) + + response = yield from self.session.get(self.url, headers=headers) + + request_info = response.request_info + assert str(request_info.url) == self.url + assert request_info.headers == headers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/tests/test_compat_pytest.py new/aioresponses-0.6.4/tests/test_compat_pytest.py --- old/aioresponses-0.6.2/tests/test_compat_pytest.py 2019-11-21 21:08:22.000000000 +0100 +++ new/aioresponses-0.6.4/tests/test_compat_pytest.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -# # -*- coding: utf-8 -*- -# from typing import Union -# -# import pytest -# from yarl import URL -# -# from aioresponses.compat import merge_params -# -# -# @pytest.fixture -# def url_with_parameters(): -# return 'http://example.com/api?foo=bar#fragment' -# -# -# @pytest.fixture -# def url_without_parameters(): -# return 'http://example.com/api?#fragment' -# -# -# def get_url(url: str, as_str: bool) -> Union[URL, str]: -# return url if as_str else URL(url) -# -# -# @pytest.mark.parametrize("as_str", (True, False)) -# def test_no_params_returns_same_url__as_str(as_str, url_with_parameters): -# url = get_url(url_with_parameters, as_str) -# assert merge_params(url, None) == URL(url_with_parameters) -# -# -# @pytest.mark.parametrize("as_str", (True, False)) -# def test_empty_params_returns_same_url__as_str(as_str, url_with_parameters): -# url = get_url(url_with_parameters, as_str) -# assert merge_params(url, {}) == URL(url_with_parameters) -# -# -# @pytest.mark.parametrize("as_str", (True, False)) -# def test_both_with_params_returns_corrected_url__as_str(as_str, -# url_with_parameters): -# url = get_url(url_with_parameters, as_str) -# assert ( -# merge_params(url, {'x': 42}) == URL('http://example.com/api?foo=bar&x=42#fragment') -# ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/tests/test_pytest.py new/aioresponses-0.6.4/tests/test_pytest.py --- old/aioresponses-0.6.2/tests/test_pytest.py 2019-11-21 21:08:22.000000000 +0100 +++ new/aioresponses-0.6.4/tests/test_pytest.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -# # -*- coding: utf-8 -*- -# import asyncio -# -# import pytest -# from aiohttp import ClientSession -# -# from aioresponses import aioresponses -# -# -# @pytest.yield_fixture -# def foo(): -# print('foo') -# with aioresponses() as m: -# yield m -# print('') -# -# -# @pytest.fixture -# def session(): -# print('session') -# return ClientSession() -# -# -# @pytest.yield_fixture() -# def event_loop(): -# loop = asyncio.new_event_loop() -# asyncio.set_event_loop(loop) -# yield loop -# loop.close() -# -# -# @pytest.mark.asyncio -# async def test_me(foo, session): -# url = 'http://example.com/api?foo=bar#fragment' -# foo.get(url, status=204) -# response = await session.get(url) -# -# assert response.status == 204 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aioresponses-0.6.2/tox.ini new/aioresponses-0.6.4/tox.ini --- old/aioresponses-0.6.2/tox.ini 2019-11-21 23:22:36.000000000 +0100 +++ new/aioresponses-0.6.4/tox.ini 2020-02-11 22:27:00.000000000 +0100 @@ -7,6 +7,8 @@ py36-aiohttp{20,21,22,23,30,31,32,33,34,35,36} py37-aiohttp-master py37-aiohttp{30,31,32,33,34,35,36} + py38-aiohttp-master + py38-aiohttp{30,31,32,33,34,35,36} skipsdist = True [testenv:flake8]