-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Better error message when comparing images #7140
Conversation
Assert statements give a better message this way.
@@ -15,6 +15,9 @@ | |||
|
|||
from PIL import Image, ImageMath, features | |||
|
|||
# overridden in conftest.py | |||
pytestconfig = {"option": {"verbose": 0}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously discussed in #6653 (comment)
Before
After
This might just be personal preference, but "got different content" grabs my attention more in the before version. |
It's still there. This change just also tells you what the different content is. |
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. |
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. |
When comparing images with
assert_image_equal()
,assert
their bytes instead ofassert
ingFalse
. 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.