-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Present AssertionError differently #183
Comments
This looks pretty cool. It seems programmatically a big lift to add to the library. Any ideas how to do this without deep modifications? Possibly need an option for minimal "location" metadata to the existing messages and then this pretty print would be a separate function abstracted from the core code. It would need a ton of test cases, since this could get buggy. Need to think about how to handle really large JSON messages with just a few errors. I'll leave this open in case people have some ideas. |
You can start smaller with a "dumb" unified-diff presentation? I'd say also "and/or add a lambda functionality to the |
I use https://github.com/javiertuya/visual-assert to assert (and soft assert) differences in strings or files. This can save the diffs in html files for further inspection and display the differences in the development environment. To display JSON differences using this approach it would require to pretty-print and sort keys. Maybe this could be an optional step after JSONassert has detected that there are differences |
It might be just me, but would you consider a different output for failed tests?
Of course, having the
expectedStr
makes this error somewhat more readable.However, even in this case, an output like the one I'm proposing will be better in my opinion (you will be able to see what values were received).
My proposal is tl;dr JSON is pretty printed, sorted, and diffed:
pytest-dev/pytest#11571
The text was updated successfully, but these errors were encountered: