Open leorochael opened 3 years ago
The json needs to be dumped back to a string otherwise an exception is thrown in the matcher. So:
if data is None:
data = json.dumps(kwargs.get("json"))
elif kwargs.get("json") is not None:
raise ValueError(
"data and json parameters can not be used at the same time"
)
I had hoped this bug was resolved with all the other aiohttp
fixes. I can provide additional details, need to fix the tests in my project first.
In
vcr/stubs/aiohttp_stubs.py:vcr_request()
, thenew_request()
coroutine checks fordata
orjson
with this:But this line assumes that
json
can only be sent ifdata
is absent. Butdata
could be present and set toNone
, along with ajson
parameter that is notNone
.In the case of a
None
indata
and a payload injson
, thejson
payload is ignored, and the cassete is recorded as:The equivalent logic in
aiohttp
itself is tolerant of aNone
being present indata
(as it must, sinceNone
is the default value of both arguments):I recommend the logic in
vcr/stubs/aiohttp_stubs.py:vcr_request()
be changed to matchaiohttp.client
: