From 4ef5205094c886155403264dd2aa88cf53eb837a Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 15 Oct 2018 02:55:59 +0100 Subject: [PATCH] support ClientResponse.text(errors=) kwarg --- tests/integration/test_aiohttp.py | 2 ++ vcr/stubs/aiohttp_stubs/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index 74aaccc..c20dc61 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -168,6 +168,8 @@ def test_aiohttp_test_client(aiohttp_client, tmpdir): assert response.status == 200 response_text = loop.run_until_complete(response.text()) assert response_text == 'hello' + response_text = loop.run_until_complete(response.text(errors='replace')) + assert response_text == 'hello' with vcr.use_cassette(str(tmpdir.join('get.yaml'))) as cassette: response = loop.run_until_complete(client.get(url)) diff --git a/vcr/stubs/aiohttp_stubs/__init__.py b/vcr/stubs/aiohttp_stubs/__init__.py index 489fcf0..f6525c7 100644 --- a/vcr/stubs/aiohttp_stubs/__init__.py +++ b/vcr/stubs/aiohttp_stubs/__init__.py @@ -28,8 +28,8 @@ class MockClientResponse(ClientResponse): async def json(self, *, encoding='utf-8', loads=json.loads, **kwargs): # NOQA: E999 return loads(self._body.decode(encoding)) - async def text(self, encoding='utf-8'): - return self._body.decode(encoding) + async def text(self, encoding='utf-8', errors='strict'): + return self._body.decode(encoding, errors=errors) async def read(self): return self._body