vcrpy icon indicating copy to clipboard operation
vcrpy copied to clipboard

body matcher gives no details when assertion fails

Open djowett opened this issue 1 year ago • 3 comments

Is there a reason that the AssertionError in the body matcher does not supply details of the error?

It is difficult to determine some test failures without it.

This is an example of my current test output.

Matchers succeeded : ['method', 'scheme', 'host', 'port', 'path', 'query']
Matchers failed :
headers - assertion failure :
{'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '889', 'Content-Type': 'application/json'} != {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br', 'Connection': 'keep-alive', 'Content-Length': '888', 'Content-Type': 'application/json'}
body - assertion failure :

(this also applies to the raw_body matcher)

I believe this was not the case before #644

If there's no good reason to avoid it, I can provide a PR to re-add it.

djowett avatar May 23 '24 09:05 djowett

I would also like this. The problem is that the body could be very big and gross. So then what? deepdiff.DeepDiff?

fiendish avatar Jul 02 '24 03:07 fiendish

I would also like this. The problem is that the body could be very big and gross. So then what? deepdiff.DeepDiff?

Hmm, I'm not sure maybe https://docs.python.org/3/library/difflib.html since it's in the stdlib?

My head isn't in this right now though, so I won't get to it soon.

djowett avatar Oct 29 '24 13:10 djowett

Also just ran into this, makes it quite difficult to debug trivial requests.

Since most bodies are small, a quick fix would be to just show eg. the first 200 characters of the raw body.

jaens avatar May 13 '25 16:05 jaens