kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 389 forks source link

httpx doesn't work anymore #565

Closed sileht closed 3 years ago

sileht commented 4 years ago

New version of httpx (>=0.15) have change httpx.Response attributes list. The current vcrpy stubs is impacted by this change:

    @patch("httpx.Response.close", MagicMock())
    @patch("httpx.Response.read", MagicMock())
    def _from_serialized_response(request, serialized_response, history=None):
        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=_from_serialized_headers(serialized_response.get("headers")),
            content=content,
            history=history or [],
        )
E       TypeError: __init__() got an unexpected keyword argument 'http_version'

.tox/py38/lib/python3.8/site-packages/vcr/stubs/httpx_stubs.py:52: TypeError
ToGoBananas commented 4 years ago

fixed in master branch

sileht commented 4 years ago

I just test 4.1.1, cassettes are not compatible with those recorded with httpx < 0.15. But I have re-recorded some cassettes it seems to works well. So I started the rerecord of everything.