]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fix aiohttp_request to properly perform aiohttp requests
authorLuiz Menezes <luiz.menezesf@gmail.com>
Fri, 4 May 2018 18:45:11 +0000 (15:45 -0300)
committerLuiz Menezes <luiz.menezesf@gmail.com>
Mon, 7 May 2018 12:25:21 +0000 (09:25 -0300)
tests/integration/aiohttp_utils.py

index 1569e7cb8c673b670f93e1333573a213032ab1c5..2f135c80439851509492a8ca71bf050a67696fc0 100644 (file)
@@ -3,11 +3,11 @@ import aiohttp
 
 async def aiohttp_request(loop, method, url, output='text', **kwargs):  # NOQA: E999
     async with aiohttp.ClientSession(loop=loop) as session:  # NOQA: E999
-        response = await session.request(method, url, **kwargs)  # NOQA: E999
-        if output == 'text':
-            content = await response.text()  # NOQA: E999
-        elif output == 'json':
-            content = await response.json()  # NOQA: E999
-        elif output == 'raw':
-            content = await response.read()  # NOQA: E999
-        return response, content
+        async with session.request(method, url, **kwargs) as response:  # NOQA: E999
+            if output == 'text':
+                content = await response.text()  # NOQA: E999
+            elif output == 'json':
+                content = await response.json()  # NOQA: E999
+            elif output == 'raw':
+                content = await response.read()  # NOQA: E999
+            return response, content