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

make it work with gzipped data

This commit is contained in:
Hernan Ezequiel Di Giorgi
2020-04-27 20:39:05 -03:00
committed by Kevin McCarthy
parent b8024de1b8
commit 79d26ebb43
2 changed files with 18 additions and 2 deletions

View File

@@ -27,15 +27,19 @@ def _to_serialized_response(httpx_reponse):
@patch("httpx.Response.close", MagicMock())
@patch("httpx.Response.read", MagicMock())
def _from_serialized_response(request, serialized_response, history=None):
return httpx.Response(
content = serialized_response.get("content").encode()
response = httpx.Response(
status_code=serialized_response.get("status_code"),
request=request,
http_version=serialized_response.get("http_version"),
headers=serialized_response.get("headers"),
content=serialized_response.get("content"),
content=content,
history=history or [],
)
response._content = content
return response
def _make_vcr_request(httpx_request, **kwargs):