You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But this line assumes that json can only be sent if data is absent. But data could be present and set to None, along with a json parameter that is not None.
In the case of a None in data and a payload in json, the json payload is ignored, and the cassete is recorded as:
interactions:
- request:
body: null
The equivalent logic in aiohttp itself is tolerant of a None being present in data (as it must, since None is the default value of both arguments):
ifdataisnotNoneandjsonisnotNone:
raiseValueError(
"data and json parameters can not be used at the same time"
)
elifjsonisnotNone:
data=payload.JsonPayload(json, dumps=self._json_serialize)
I recommend the logic in vcr/stubs/aiohttp_stubs.py:vcr_request() be changed to match aiohttp.client:
data=kwargs.get("data")
ifdataisNone:
data=kwargs.get("json")
elifkwargs.get("json") isnotNone:
raiseValueError(
"data and json parameters can not be used at the same time"
)
The text was updated successfully, but these errors were encountered:
The json needs to be dumped back to a string otherwise an exception is thrown in the matcher. So:
ifdataisNone:
data=json.dumps(kwargs.get("json"))
elifkwargs.get("json") isnotNone:
raiseValueError(
"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
:The text was updated successfully, but these errors were encountered: