From 75cb067e2911aa8fcbb9e10657a79f97925f3e64 Mon Sep 17 00:00:00 2001 From: Luiz Menezes Date: Sat, 7 Jul 2018 23:56:39 -0300 Subject: [PATCH] Fix content type being passed to aiohttp response stub --- tests/integration/aiohttp_utils.py | 5 +++-- vcr/stubs/aiohttp_stubs/__init__.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/integration/aiohttp_utils.py b/tests/integration/aiohttp_utils.py index 4fdf63e..b0b2dd6 100644 --- a/tests/integration/aiohttp_utils.py +++ b/tests/integration/aiohttp_utils.py @@ -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() diff --git a/vcr/stubs/aiohttp_stubs/__init__.py b/vcr/stubs/aiohttp_stubs/__init__.py index 7761ab5..4f2c111 100644 --- a/vcr/stubs/aiohttp_stubs/__init__.py +++ b/vcr/stubs/aiohttp_stubs/__init__.py @@ -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