]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Allow test failure on pypy3+aiohttp
authorLuiz Menezes <luiz.menezesf@gmail.com>
Tue, 8 May 2018 12:45:17 +0000 (09:45 -0300)
committerLuiz Menezes <luiz.menezesf@gmail.com>
Tue, 8 May 2018 12:45:17 +0000 (09:45 -0300)
.travis.yml
tests/integration/aiohttp_utils.py

index 0e432701f7a71ea9c5e263f232408681fce7ee3e..8a2fa24ee39c62f8d9597d94ca0cc8830176674c 100644 (file)
@@ -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
index 5fadbfee7121b5d1f428832e9282e7f69b556bc9..193c3aa3ffcc6a3d45a23fdad5f86c1b28472857 100644 (file)
@@ -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()