From 140bc2ee74f251b01927b37517d1aeb0f64c10b7 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Tue, 8 May 2018 09:45:17 -0300 Subject: [PATCH] Allow test failure on pypy3+aiohttp --- .travis.yml | 2 ++ tests/integration/aiohttp_utils.py | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) 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) - return response, content + 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() + + response_ctx._resp.close() + yield from session.close()