mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 09:35:34 +00:00
Fix aiohttp stub to support version >= 3.1.0
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import asyncio
|
||||
import aiohttp
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def aiohttp_request(loop, method, url, output='text', **kwargs):
|
||||
async def aiohttp_request(loop, method, url, output='text', **kwargs):
|
||||
with aiohttp.ClientSession(loop=loop) as session:
|
||||
response = yield from session.request(method, url, **kwargs) # NOQA: E999
|
||||
response = await session.request(method, url, **kwargs) # NOQA: E999
|
||||
if output == 'text':
|
||||
content = yield from response.text() # NOQA: E999
|
||||
content = await response.text() # NOQA: E999
|
||||
elif output == 'json':
|
||||
content = yield from response.json() # NOQA: E999
|
||||
content = await response.json() # NOQA: E999
|
||||
elif output == 'raw':
|
||||
content = yield from response.read() # NOQA: E999
|
||||
content = await response.read() # NOQA: E999
|
||||
return response, content
|
||||
|
||||
Reference in New Issue
Block a user