Skip to content
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

Log expected & actual color in image access tests #6899

Merged
merged 3 commits into from
Mar 4, 2023

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Jan 16, 2023

No description provided.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, here's a variable naming suggestion.

Tests/test_image_access.py Outdated Show resolved Hide resolved
Tests/test_image_access.py Outdated Show resolved Hide resolved
Tests/test_image_access.py Outdated Show resolved Hide resolved
Tests/test_image_access.py Outdated Show resolved Hide resolved
Tests/test_image_access.py Outdated Show resolved Hide resolved
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@radarhere
Copy link
Member

If I break the test in main, I get

E       AssertionError: put/getpixel roundtrip failed for mode I;16B, color 32766
E       assert 32767 == 32766
E        +  where 32767 = <bound method Image.getpixel of <PIL.Image.Image image mode=I;16B size=1x1 at 0x104945F70>>((0, 0))
E        +    where <bound method Image.getpixel of <PIL.Image.Image image mode=I;16B size=1x1 at 0x104945F70>> = <PIL.Image.Image image mode=I;16B size=1x1 at 0x104945F70>.getpixel

If I break the test with this branch, I get

E       AssertionError: put/getpixel roundtrip failed for mode I;16, expected 32766 got 32767
E       assert 32767 == 32766

I can see that the argument that the 'where' lines being removed makes it tidier, but I'm not convinced that the values need to be part of the error message, as they're already listed in the next line?

It is listed in the summary now as

FAILED Tests/test_image_access.py::TestCffiGetPixel::test_signedness[32769-I;16B] - AssertionError: put/getpixel roundtrip failed for mode I;16B, expected 32768 got 32769

where the actual value wouldn't be listed otherwise. I'm not opposed to that, I just wonder if this is trying to fight against pytest's decision to have the summary not include more details.

@Yay295
Copy link
Contributor Author

Yay295 commented Jan 18, 2023

The only change is from "color 32766" to "expected 32766 got 32767". I don't think that's excessive for an error message. Also, if a message isn't provided to the assert, the summary message will be just "assert 32767 == 32766". So the current summary actually gives less information than the default.

@radarhere radarhere merged commit 6ee157c into python-pillow:main Mar 4, 2023
@Yay295 Yay295 deleted the image_access_test_log_values branch March 4, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants