From f98684e8aa4a2314d3429ac1af9a384fac48fbf8 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 00:21:49 -0300 Subject: [PATCH 01/14] add support for aiohttp --- vcr/patch.py | 22 ++++++++++- vcr/stubs/aiohttp_stubs.py | 76 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 vcr/stubs/aiohttp_stubs.py diff --git a/vcr/patch.py b/vcr/patch.py index 0c543549..ac1127a4 100644 --- a/vcr/patch.py +++ b/vcr/patch.py @@ -80,6 +80,13 @@ _CurlAsyncHTTPClient_fetch_impl = \ tornado.curl_httpclient.CurlAsyncHTTPClient.fetch_impl +try: + import aiohttp.client +except ImportError: # pragma: no cover + pass +else: + _AiohttpClientSessionRequest = aiohttp.client.ClientSession._request + class CassettePatcherBuilder(object): @@ -98,7 +105,7 @@ def __init__(self, cassette): def build(self): return itertools.chain( self._httplib(), self._requests(), self._boto3(), self._urllib3(), - self._httplib2(), self._boto(), self._tornado(), + self._httplib2(), self._boto(), self._tornado(), self._aiohttp(), self._build_patchers_from_mock_triples( self._cassette.custom_patches ), @@ -273,6 +280,19 @@ def _tornado(self): ) yield curl.CurlAsyncHTTPClient, 'fetch_impl', new_fetch_impl + @_build_patchers_from_mock_triples_decorator + def _aiohttp(self): + try: + import aiohttp.client as client + except ImportError: # pragma: no cover + pass + else: + from .stubs.aiohttp_stubs import vcr_request + new_request = vcr_request( + self._cassette, _AiohttpClientSessionRequest + ) + yield client.ClientSession, '_request', new_request + def _urllib3_patchers(self, cpool, stubs): http_connection_remover = ConnectionRemover( self._get_cassette_subclass(stubs.VCRRequestsHTTPConnection) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py new file mode 100644 index 00000000..070a0f7a --- /dev/null +++ b/vcr/stubs/aiohttp_stubs.py @@ -0,0 +1,76 @@ +'''Stubs for aiohttp HTTP clients''' +from __future__ import absolute_import + +import functools +import json + +from aiohttp import ClientResponse +from multidict import CIMultiDictProxy + +from vcr.request import Request + + +class MockClientResponse(ClientResponse): + # TODO: get encoding from header + async def json(self, *, encoding='utf-8', loads=json.loads): + return loads(self.content.decode(encoding)) + + async def text(self, encoding='utf-8'): + return self.content.decode(encoding) + + async def release(self): + self.close() + + +def vcr_request(cassette, real_request): + + @functools.wraps(real_request) + async def new_request(self, method, url, **kwargs): + headers = kwargs.get('headers') + headers = self._prepare_headers(headers) + data = kwargs.get('data') + + vcr_request = Request(method, url, data, headers) + + if cassette.can_play_response_for(vcr_request): + vcr_response = cassette.play_response(vcr_request) + + response = MockClientResponse( + method, + vcr_response.get('url'), + ) + response.status = vcr_response['status']['code'] + response.content = vcr_response['body']['string'] + response.reason = vcr_response['status']['message'] + response.headers = CIMultiDictProxy(headers) + + return response + + if cassette.write_protected and cassette.filter_request(vcr_request): + response = MockClientResponse( + method, + vcr_response.get('url'), + ) + response.status = 599 + response.content = ("No match for the request (%r) was found. " + "Can't overwrite existing cassette (%r) in " + "your current record mode (%r).") + response.close() + return response + + response = await real_request(self, method, url, **kwargs) + + vcr_response = { + 'status': { + 'code': response.status, + 'message': response.reason, + }, + 'headers': response.headers, + 'body': {'string': await response.text()}, + 'url': response.url, + } + cassette.append(vcr_request, vcr_response) + + return response + + return new_request From 17afa82bf4bf754c98506c9afcc486b41c5c3556 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:37:51 -0300 Subject: [PATCH 02/14] remove CIMultiDictProxy from aiohttp_stubs.vcr_request --- vcr/stubs/aiohttp_stubs.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index 070a0f7a..5dcbb158 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -5,7 +5,6 @@ import json from aiohttp import ClientResponse -from multidict import CIMultiDictProxy from vcr.request import Request @@ -35,22 +34,16 @@ async def new_request(self, method, url, **kwargs): if cassette.can_play_response_for(vcr_request): vcr_response = cassette.play_response(vcr_request) - response = MockClientResponse( - method, - vcr_response.get('url'), - ) + response = MockClientResponse(method, vcr_response.get('url')) response.status = vcr_response['status']['code'] response.content = vcr_response['body']['string'] response.reason = vcr_response['status']['message'] - response.headers = CIMultiDictProxy(headers) + response.headers = vcr_response['headers'] return response if cassette.write_protected and cassette.filter_request(vcr_request): - response = MockClientResponse( - method, - vcr_response.get('url'), - ) + response = MockClientResponse(method, url) response.status = 599 response.content = ("No match for the request (%r) was found. " "Can't overwrite existing cassette (%r) in " From 3355bd01eb74251b8267c5e26d24aee55e4abe8f Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:39:09 -0300 Subject: [PATCH 03/14] fix aiohttp response closing --- vcr/stubs/aiohttp_stubs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index 5dcbb158..c9d1fc38 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -18,7 +18,7 @@ async def text(self, encoding='utf-8'): return self.content.decode(encoding) async def release(self): - self.close() + pass def vcr_request(cassette, real_request): @@ -40,6 +40,7 @@ async def new_request(self, method, url, **kwargs): response.reason = vcr_response['status']['message'] response.headers = vcr_response['headers'] + response.close() return response if cassette.write_protected and cassette.filter_request(vcr_request): @@ -58,7 +59,7 @@ async def new_request(self, method, url, **kwargs): 'code': response.status, 'message': response.reason, }, - 'headers': response.headers, + 'headers': dict(response.headers), 'body': {'string': await response.text()}, 'url': response.url, } From f71d28d10e54983906eccad923dfc2126bf8e30b Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:39:46 -0300 Subject: [PATCH 04/14] fix aiohttp_stubs.vcr_request error message --- vcr/stubs/aiohttp_stubs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index c9d1fc38..d4832609 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -46,9 +46,10 @@ async def new_request(self, method, url, **kwargs): if cassette.write_protected and cassette.filter_request(vcr_request): response = MockClientResponse(method, url) response.status = 599 - response.content = ("No match for the request (%r) was found. " - "Can't overwrite existing cassette (%r) in " - "your current record mode (%r).") + msg = ("No match for the request {!r} was found. Can't overwrite " + "existing cassette {!r} in your current record mode {!r}.") + msg = msg.format(vcr_request, cassette._path, cassette.record_mode) + response.content = msg.encode() response.close() return response From 8851571ba71b1377152f1d8c68022d7ebac9050d Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:40:04 -0300 Subject: [PATCH 05/14] add integration tests for aiohttp --- tests/integration/test_aiohttp.py | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/integration/test_aiohttp.py diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py new file mode 100644 index 00000000..ab1112c1 --- /dev/null +++ b/tests/integration/test_aiohttp.py @@ -0,0 +1,87 @@ +import asyncio + +import aiohttp +import pytest +import vcr + + +@asyncio.coroutine +def request(session, method, url, as_text, **kwargs): + response = yield from session.request(method, url, **kwargs) + return response, (yield from response.text()) if as_text else (yield from response.json()) + + +def get(url, as_text=True, **kwargs): + loop = asyncio.get_event_loop() + with aiohttp.ClientSession() as session: + task = loop.create_task(request(session, 'GET', url, as_text, **kwargs)) + return loop.run_until_complete(task) + + +def post(url, as_text=True, **kwargs): + loop = asyncio.get_event_loop() + with aiohttp.ClientSession() as session: + task = loop.create_task(request(session, 'POST', url, as_text, **kwargs)) + return loop.run_until_complete(task) + + +@pytest.fixture(params=["https", "http"]) +def scheme(request): + '''Fixture that returns both http and https.''' + return request.param + + +def test_status(tmpdir, scheme): + url = scheme + '://httpbin.org' + with vcr.use_cassette(str(tmpdir.join('status.yaml'))): + response, _ = get(url) + + with vcr.use_cassette(str(tmpdir.join('status.yaml'))) as cassette: + cassette_response, _ = get(url) + assert cassette_response.status == response.status + assert cassette.play_count == 1 + + +def test_headers(tmpdir, scheme): + url = scheme + '://httpbin.org' + with vcr.use_cassette(str(tmpdir.join('headers.yaml'))): + response, _ = get(url) + + with vcr.use_cassette(str(tmpdir.join('headers.yaml'))) as cassette: + cassette_response, _ = get(url) + assert cassette_response.headers == response.headers + assert cassette.play_count == 1 + + +def test_text(tmpdir, scheme): + url = scheme + '://httpbin.org' + with vcr.use_cassette(str(tmpdir.join('text.yaml'))): + _, response_text = get(url) + + with vcr.use_cassette(str(tmpdir.join('text.yaml'))) as cassette: + _, cassette_response_text = get(url) + assert cassette_response_text == response_text + assert cassette.play_count == 1 + + +def test_json(tmpdir, scheme): + url = scheme + '://httpbin.org/get' + with vcr.use_cassette(str(tmpdir.join('json.yaml'))): + _, response_json = get(url, as_text=False) + + with vcr.use_cassette(str(tmpdir.join('json.yaml'))) as cassette: + _, cassette_response_json = get(url, as_text=False) + assert cassette_response_json == response_json + assert cassette.play_count == 1 + + +def test_post(tmpdir, scheme): + data = {'key1': 'value1', 'key2': 'value2'} + url = scheme + '://httpbin.org/post' + with vcr.use_cassette(str(tmpdir.join('post.yaml'))): + _, response_json = post(url, data=data) + + with vcr.use_cassette(str(tmpdir.join('post.yaml'))) as cassette: + _, cassette_response_json = post(url, data=data) + assert cassette_response_json == response_json + assert cassette.play_count == 1 From 77ae99bfda704a1fb7d64b1f613fa90773085c41 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:44:11 -0300 Subject: [PATCH 06/14] add aiohttp to tests config --- .travis.yml | 6 ++++++ tox.ini | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 404d2ba6..289f3071 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,12 @@ env: - TOX_SUFFIX="urllib3110" - TOX_SUFFIX="tornado3" - TOX_SUFFIX="tornado4" + - TOX_SUFFIX="aiohttp" matrix: allow_failures: - env: TOX_SUFFIX="boto" - env: TOX_SUFFIX="boto3" + - TOX_SUFFIX="aiohttp" exclude: - env: TOX_SUFFIX="boto" python: 3.3 @@ -35,6 +37,10 @@ matrix: python: 3.4 - env: TOX_SUFFIX="requests1" python: 3.5 + - env: TOX_SUFFIX="aiohttp" + python: 3.4 + - env: TOX_SUFFIX="aiohttp" + python: 3.5 python: - 2.6 - 2.7 diff --git a/tox.ini b/tox.ini index 77ce9b71..6c7d2a5a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py26,py27,py33,py34,pypy,pypy3}-{flakes,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3} +envlist = {py26,py27,py33,py34,pypy,pypy3}-{flakes,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp} [testenv:flakes] skipsdist = True @@ -38,6 +38,7 @@ deps = {py26,py27,py33,py34}-tornado4: pycurl boto: boto boto3: boto3 + aiohttp: aiohttp [flake8] max_line_length = 110 From 1167b9ea4ee443253b635805a1640b95b8808ad5 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 13:55:34 -0300 Subject: [PATCH 07/14] fix .travis.yml --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 289f3071..30545e2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,6 @@ matrix: allow_failures: - env: TOX_SUFFIX="boto" - env: TOX_SUFFIX="boto3" - - TOX_SUFFIX="aiohttp" exclude: - env: TOX_SUFFIX="boto" python: 3.3 @@ -38,9 +37,13 @@ matrix: - env: TOX_SUFFIX="requests1" python: 3.5 - env: TOX_SUFFIX="aiohttp" - python: 3.4 + python: 2.6 - env: TOX_SUFFIX="aiohttp" - python: 3.5 + python: 2.7 + - env: TOX_SUFFIX="aiohttp" + python: 3.3 + - env: TOX_SUFFIX="aiohttp" + python: pypy python: - 2.6 - 2.7 From 574b22a62ab080a09c1b63bc363784f5089805fe Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 4 Aug 2016 18:12:28 -0300 Subject: [PATCH 08/14] remove async/await from aiohttp_stubs to support python 3.4 --- .travis.yml | 1 + vcr/stubs/aiohttp_stubs.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30545e2f..1ff60437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ matrix: allow_failures: - env: TOX_SUFFIX="boto" - env: TOX_SUFFIX="boto3" + - env: TOX_SUFFIX="aiohttp" exclude: - env: TOX_SUFFIX="boto" python: 3.3 diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index d4832609..6fa074e4 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -1,6 +1,7 @@ '''Stubs for aiohttp HTTP clients''' from __future__ import absolute_import +import asyncio import functools import json @@ -11,20 +12,24 @@ class MockClientResponse(ClientResponse): # TODO: get encoding from header - async def json(self, *, encoding='utf-8', loads=json.loads): + @asyncio.coroutine + def json(self, *, encoding='utf-8', loads=json.loads): return loads(self.content.decode(encoding)) - async def text(self, encoding='utf-8'): + @asyncio.coroutine + def text(self, encoding='utf-8'): return self.content.decode(encoding) - async def release(self): + @asyncio.coroutine + def release(self): pass def vcr_request(cassette, real_request): @functools.wraps(real_request) - async def new_request(self, method, url, **kwargs): + @asyncio.coroutine + def new_request(self, method, url, **kwargs): headers = kwargs.get('headers') headers = self._prepare_headers(headers) data = kwargs.get('data') @@ -53,7 +58,7 @@ async def new_request(self, method, url, **kwargs): response.close() return response - response = await real_request(self, method, url, **kwargs) + response = yield from real_request(self, method, url, **kwargs) vcr_response = { 'status': { @@ -61,7 +66,7 @@ async def new_request(self, method, url, **kwargs): 'message': response.reason, }, 'headers': dict(response.headers), - 'body': {'string': await response.text()}, + 'body': {'string': (yield from response.text())}, 'url': response.url, } cassette.append(vcr_request, vcr_response) From ce14de8251531f6a001447c7f8857cc12b795287 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Wed, 10 Aug 2016 15:56:19 -0300 Subject: [PATCH 09/14] fix tests --- .travis.yml | 1 - tests/integration/test_aiohttp.py | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ff60437..30545e2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,6 @@ matrix: allow_failures: - env: TOX_SUFFIX="boto" - env: TOX_SUFFIX="boto3" - - env: TOX_SUFFIX="aiohttp" exclude: - env: TOX_SUFFIX="boto" python: 3.3 diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index ab1112c1..1ae2fe1b 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -1,8 +1,11 @@ -import asyncio - -import aiohttp import pytest -import vcr +asyncio = pytest.importorskip("boto3") + +import asyncio # NOQA + +import aiohttp # NOQA +import pytest # NOQA +import vcr # NOQA @asyncio.coroutine From 609d8e35befd315df56a73295868785fe7a9f6c6 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Wed, 10 Aug 2016 17:42:13 -0300 Subject: [PATCH 10/14] fix test_aiohttp --- tests/integration/test_aiohttp.py | 13 +++++-------- tests/integration/utils.py | 7 +++++++ 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 tests/integration/utils.py diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index 1ae2fe1b..73bd48db 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -1,30 +1,27 @@ import pytest -asyncio = pytest.importorskip("boto3") +aiohttp = pytest.importorskip("aiohttp") import asyncio # NOQA +import sys # NOQA import aiohttp # NOQA import pytest # NOQA import vcr # NOQA - -@asyncio.coroutine -def request(session, method, url, as_text, **kwargs): - response = yield from session.request(method, url, **kwargs) - return response, (yield from response.text()) if as_text else (yield from response.json()) +from .utils import aiohttp_request # NOQA def get(url, as_text=True, **kwargs): loop = asyncio.get_event_loop() with aiohttp.ClientSession() as session: - task = loop.create_task(request(session, 'GET', url, as_text, **kwargs)) + task = loop.create_task(aiohttp_request(session, 'GET', url, as_text, **kwargs)) return loop.run_until_complete(task) def post(url, as_text=True, **kwargs): loop = asyncio.get_event_loop() with aiohttp.ClientSession() as session: - task = loop.create_task(request(session, 'POST', url, as_text, **kwargs)) + task = loop.create_task(aiohttp_request(session, 'POST', url, as_text, **kwargs)) return loop.run_until_complete(task) diff --git a/tests/integration/utils.py b/tests/integration/utils.py new file mode 100644 index 00000000..16731f4d --- /dev/null +++ b/tests/integration/utils.py @@ -0,0 +1,7 @@ +import asyncio + + +@asyncio.coroutine +def aiohttp_request(session, method, url, as_text, **kwargs): + response = yield from session.request(method, url, **kwargs) + return response, (yield from response.text()) if as_text else (yield from response.json()) From 9a5214888b1e52a8d99614e8d69e6dda171fe779 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Wed, 10 Aug 2016 18:24:13 -0300 Subject: [PATCH 11/14] fix tox's flakes tests --- .travis.yml | 2 ++ tox.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 30545e2f..f1614a06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,8 @@ matrix: python: 3.3 - env: TOX_SUFFIX="aiohttp" python: pypy + - env: TOX_SUFFIX="aiohttp" + python: pypy3 python: - 2.6 - 2.7 diff --git a/tox.ini b/tox.ini index 6c7d2a5a..fa60b54e 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = {py26,py27,py33,py34,pypy,pypy3}-{flakes,requests27,requests26,request skipsdist = True commands = flake8 --version - flake8 --exclude="./docs/conf.py" + flake8 --exclude=./docs/conf.py,./.tox/ pyflakes ./docs/conf.py deps = flake8 From 066752aa0b13b207d1d8ad089958a5d013b68bbf Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 11 Aug 2016 08:32:47 -0300 Subject: [PATCH 12/14] rename file --- tests/integration/{utils.py => aiohttp_utils.py} | 0 tests/integration/test_aiohttp.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/integration/{utils.py => aiohttp_utils.py} (100%) diff --git a/tests/integration/utils.py b/tests/integration/aiohttp_utils.py similarity index 100% rename from tests/integration/utils.py rename to tests/integration/aiohttp_utils.py diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index 73bd48db..1aa9c057 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -8,7 +8,7 @@ import pytest # NOQA import vcr # NOQA -from .utils import aiohttp_request # NOQA +from .aiohttp_utils import aiohttp_request # NOQA def get(url, as_text=True, **kwargs): From c65ff0e7b331032ffa83690a4fb359b7ac2c8697 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Thu, 11 Aug 2016 19:44:21 -0300 Subject: [PATCH 13/14] fix flake8: ignore yield from syntax errors --- tests/integration/aiohttp_utils.py | 4 ++-- vcr/stubs/aiohttp_stubs.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/aiohttp_utils.py b/tests/integration/aiohttp_utils.py index 16731f4d..195e5eb2 100644 --- a/tests/integration/aiohttp_utils.py +++ b/tests/integration/aiohttp_utils.py @@ -3,5 +3,5 @@ @asyncio.coroutine def aiohttp_request(session, method, url, as_text, **kwargs): - response = yield from session.request(method, url, **kwargs) - return response, (yield from response.text()) if as_text else (yield from response.json()) + response = yield from session.request(method, url, **kwargs) # NOQA: E999 + return response, (yield from response.text()) if as_text else (yield from response.json()) # NOQA: E999 diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index 6fa074e4..a19be693 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -13,7 +13,7 @@ class MockClientResponse(ClientResponse): # TODO: get encoding from header @asyncio.coroutine - def json(self, *, encoding='utf-8', loads=json.loads): + def json(self, *, encoding='utf-8', loads=json.loads): # NOQA: E999 return loads(self.content.decode(encoding)) @asyncio.coroutine @@ -58,7 +58,7 @@ def new_request(self, method, url, **kwargs): response.close() return response - response = yield from real_request(self, method, url, **kwargs) + response = yield from real_request(self, method, url, **kwargs) # NOQA: E999 vcr_response = { 'status': { @@ -66,7 +66,7 @@ def new_request(self, method, url, **kwargs): 'message': response.reason, }, 'headers': dict(response.headers), - 'body': {'string': (yield from response.text())}, + 'body': {'string': (yield from response.text())}, # NOQA: E999 'url': response.url, } cassette.append(vcr_request, vcr_response) From 265a158fe7109e7930a00c87961a31013051b4af Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Fri, 12 Aug 2016 13:50:29 -0300 Subject: [PATCH 14/14] remove py26-flakes test --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f1614a06..b76b6240 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,8 @@ matrix: - env: TOX_SUFFIX="boto" - env: TOX_SUFFIX="boto3" exclude: + - env: TOX_SUFFIX="flakes" + python: 2.6 - env: TOX_SUFFIX="boto" python: 3.3 - env: TOX_SUFFIX="boto"