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

aiohttp: Allow both data and json arguments (#624)

If at least one of them is `None`.

Previously, a `data=None` parameter would cause the `json` parameter to
be ignored, resulting in an empty request body payload on the cassette.
This commit is contained in:
Leonardo Rochael Almeida
2025-12-08 15:13:51 +01:00
committed by GitHub
parent b28316ab10
commit 31d8c3498b
2 changed files with 32 additions and 8 deletions

View File

@@ -245,7 +245,11 @@ def vcr_request(cassette, real_request):
headers = kwargs.get("headers")
auth = kwargs.get("auth")
headers = self._prepare_headers(headers)
data = kwargs.get("data", kwargs.get("json"))
data = kwargs.get("data")
if data is None:
data = kwargs.get("json")
elif kwargs.get("json") is not None:
raise ValueError("data and json parameters can not be used at the same time")
params = kwargs.get("params")
cookies = kwargs.get("cookies")