mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Allow test failure on pypy3+aiohttp
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user