Better error message when comparing images#7140
Closed
Yay295 wants to merge 3 commits intopython-pillow:mainfrom
Closed
Better error message when comparing images#7140Yay295 wants to merge 3 commits intopython-pillow:mainfrom
Yay295 wants to merge 3 commits intopython-pillow:mainfrom
Conversation
Assert statements give a better message this way.
Closed
radarhere
reviewed
May 7, 2023
| from PIL import Image, ImageMath, features | ||
|
|
||
| # overridden in conftest.py | ||
| pytestconfig = {"option": {"verbose": 0}} |
Member
|
Before After This might just be personal preference, but "got different content" grabs my attention more in the before version. |
Contributor
Author
|
It's still there. This change just also tells you what the different content is. |
Member
|
Yes, but I think in 99% of cases, the difference in bytes is not going to be meaningful to me as a human - it is highly likely that I'd want to visually compare the images. I'm saying that I think placing 'got different content' more prominently is more helpful. |
Member
|
Agreed, we don't need to print out bytes to the screen. If someone does want to see them, they temporarily can add prints to the test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When comparing images with
assert_image_equal(),asserttheir bytes instead ofassertingFalse. This gives a better error message:However, if the verbosity is too high, it will show a diff of the full image bytes. We can avoid this by temporarily changing the verbosity.