vcrpy
vcrpy copied to clipboard
Changed how json is retrieved from kwargs, updated tests [aiohttp]
trafficstars
This PR fixes https://github.com/kevin1024/vcrpy/issues/507
Current implementation works only when we send requests using session.request("POST", url, json={'a': 1}).
When session.post(url, **kwargs) is used, kwargs will look like this:
{'data': None, 'json': {'a': 1}}
When using session.post/session.put/session.put, 'data' will always be present in kwargs (source)
This is where data = kwargs.get("data", kwargs.get("json")) retrieves None value and why request body ends up to be empty in saved cassette.
I also updated tests to cover this issue.