vcrpy icon indicating copy to clipboard operation
vcrpy copied to clipboard

httpx cassettes not compatible with vcr format

Open geraxe opened this issue 5 years ago • 2 comments
trafficstars

httpx not worked from box if we create simple test

import pytest
import httpx


@pytest.mark.vcr()
def test_iana():
    response = httpx.get('http://www.iana.org/domains/reserved')
    assert b'Example domains' in response.content

and run it pytest --record-mode=once tests/test_vcr.py

we have error with cassette file format

>           new_body = decompress_body(response["body"]["string"], encoding)
E           KeyError: 'body'

vcr/filters.py:158: KeyError

because cassette file format for httpx uses content parameter, but all other stubs use body.string parameters to save and filter result

and if we will use existing cassettes with httpx it won`t work for the same reason

geraxe avatar Aug 04 '20 16:08 geraxe

#591

geraxe avatar May 25 '21 12:05 geraxe

Hey,

interesting that this issue is open for so long. We are replacing requests by httpx in more and more projects. So it would be great to get this issue fixed :smiley:

Thanks a lot for this great project :+1:

finswimmer avatar Aug 24 '23 04:08 finswimmer