1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

CHANGE: return None from json if body is empty

This commit is contained in:
Stanislav Evseev
2018-11-08 18:41:07 +01:00
parent d682e7b19a
commit 7c14d81ab1
3 changed files with 36 additions and 1 deletions

View File

@@ -30,7 +30,11 @@ class MockClientResponse(ClientResponse):
)
async def json(self, *, encoding='utf-8', loads=json.loads, **kwargs): # NOQA: E999
return loads(self._body.decode(encoding))
stripped = self._body.strip()
if not stripped:
return None
return loads(stripped.decode(encoding))
async def text(self, encoding='utf-8', errors='strict'):
return self._body.decode(encoding, errors=errors)