hjwp / pytest-icdiff

better error messages for assert equals in pytest
The Unlicense
312 stars 18 forks source link

Better visualize differences in multiline strings #47

Closed MaksimMisin closed 7 months ago

MaksimMisin commented 7 months ago

I had the same issue as https://github.com/hjwp/pytest-icdiff/issues/14 where my multiline string difference was not very readable:

image

I added a command line option --icdiff-multiline-string. Running the same test with pytest --icdiff-multiline-string -vv now returns a significantly more readable diff:

image
hjwp commented 7 months ago

thanks very much for the suggestion, and the PR! I think I'd defintely want something to improve string diffs.

It occurs to me - wouldnt' we maybe want to do this kind of non-pprint diff on any string? like, all the time, and then we wouldn't need a special CLI option?

i'd be keen to merge this without the CLI option, and just with an if that checks if both left and right are str.

also we'd need a test.

MaksimMisin commented 7 months ago

Thanks for the comments, I only added this option because I was afraid the pprint-ed strings were useful in certain situations.

LMK if you want more tests added.

MaksimMisin commented 7 months ago

Do you think you can merge the PR or is there anything missing?

hjwp commented 7 months ago

merged with thanks! I might try and find the time to fiddle with that test assertion to make it more readable, but otherwise all good for now! will throw up a new release when i get a moment...