]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fix content type being passed to aiohttp response stub
authorLuiz Menezes <luiz.menezesf@gmail.com>
Sun, 8 Jul 2018 02:56:39 +0000 (23:56 -0300)
committerLuiz Menezes <luiz.menezesf@gmail.com>
Sun, 8 Jul 2018 02:56:39 +0000 (23:56 -0300)
tests/integration/aiohttp_utils.py
vcr/stubs/aiohttp_stubs/__init__.py

index 4fdf63e016cc777203d326934b2505ef8eebff5f..b0b2dd65a88a17d4b0e1f50f2616e623a1475b92 100644 (file)
@@ -5,7 +5,7 @@ import aiohttp
 
 
 @asyncio.coroutine
-def aiohttp_request(loop, method, url, output='text', encoding='utf-8', **kwargs):
+def aiohttp_request(loop, method, url, output='text', encoding='utf-8', content_type=None, **kwargs):
     session = aiohttp.ClientSession(loop=loop)
     response_ctx = session.request(method, url, **kwargs)
 
@@ -13,7 +13,8 @@ def aiohttp_request(loop, method, url, output='text', encoding='utf-8', **kwargs
     if output == 'text':
         content = yield from response.text()
     elif output == 'json':
-        content = yield from response.json(encoding=encoding)
+        content_type = content_type or 'application/json'
+        content = yield from response.json(encoding=encoding, content_type=content_type)
     elif output == 'raw':
         content = yield from response.read()
 
index 7761ab5603ab0c1bb21de802b3865b6195bc5c74..4f2c1111061d021b64202fe21dce87e1aa01c313 100644 (file)
@@ -27,7 +27,7 @@ class MockClientResponse(ClientResponse):
 
     # TODO: get encoding from header
     @asyncio.coroutine
-    def json(self, *, encoding='utf-8', loads=json.loads):  # NOQA: E999
+    def json(self, *, encoding='utf-8', loads=json.loads, **kwargs):  # NOQA: E999
         return loads(self._body.decode(encoding))
 
     @asyncio.coroutine