]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
support ClientResponse.text(errors=) kwarg text-encoding-errors-kwarg
authorThomas Grainger <tagrain@gmail.com>
Mon, 15 Oct 2018 01:55:59 +0000 (02:55 +0100)
committerThomas Grainger <tagrain@gmail.com>
Mon, 15 Oct 2018 02:00:19 +0000 (03:00 +0100)
tests/integration/test_aiohttp.py
vcr/stubs/aiohttp_stubs/__init__.py

index 74aaccc347026489abc0e6ef9dc7cd8e812ecb3a..c20dc61bed11d10b822d721761db41ce4f02ca1d 100644 (file)
@@ -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))
index 489fcf036fa47658c9d38e4f56205cf520a191a1..f6525c79e30da5cefedfb9ff3e71d3699b3bae3b 100644 (file)
@@ -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