From: Luiz Menezes Date: Tue, 8 May 2018 12:45:17 +0000 (-0300) Subject: Allow test failure on pypy3+aiohttp X-Git-Tag: v1.12.0~1^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=140bc2ee74f251b01927b37517d1aeb0f64c10b7;p=vcrpy.git Allow test failure on pypy3+aiohttp --- diff --git a/.travis.yml b/.travis.yml index 0e43270..8a2fa24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,8 @@ matrix: python: 2.7 - env: TOX_SUFFIX="aiohttp" python: pypy + - env: TOX_SUFFIX="aiohttp" + python: "pypy3.5-5.9.0" python: - 2.7 - 3.5 diff --git a/tests/integration/aiohttp_utils.py b/tests/integration/aiohttp_utils.py index 5fadbfe..193c3aa 100644 --- a/tests/integration/aiohttp_utils.py +++ b/tests/integration/aiohttp_utils.py @@ -1,16 +1,21 @@ # flake8: noqa +import asyncio + import aiohttp -async def aiohttp_request(loop, method, url, output='text', - encoding='utf-8', headers=None, **kwargs): - async with aiohttp.ClientSession(loop=loop, headers=headers or {}) as session: - async with session.request(method, url, **kwargs) as response: - if output == 'text': - content = await response.text() - elif output == 'json': - content = await response.json(encoding=encoding) - elif output == 'raw': - content = await response.read() +@asyncio.coroutine +def aiohttp_request(loop, method, url, output='text', encoding='utf-8', **kwargs): + session = aiohttp.ClientSession(loop=loop) + response_ctx = session.request(method, url, **kwargs) + + response = yield from response_ctx.__aenter__() + if output == 'text': + content = yield from response.text() + elif output == 'json': + content = yield from response.json(encoding=encoding) + elif output == 'raw': + content = yield from response.read() - return response, content + response_ctx._resp.close() + yield from session.close()