Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Tests for byte methods

Open Yay295 opened this issue 2 years ago • 4 comments

Added some tests for Image methods that deal with bytes, and a test that helper.hopper() works for all image modes.

One of the tests failed though: https://github.com/Yay295/Pillow/actions/runs/5237154342/jobs/9455150887 FAILED Tests/test_image.py::TestImageBytes::test_pixels_after_getdata_putdata[I;16N-1-2] - assert (1, 1029, 515, 1543) == (256, 1284, 770, 1798)

For some reason doing image.putdata(image.getdata()) on an I;16N image on a big-endian maching (s390x) changes the pixels.

Yay295 avatar Jun 11 '23 20:06 Yay295

Looks like the problem is here:

https://github.com/python-pillow/Pillow/blob/706f8f6465cc1194d4a06b0a3cd6383023b822e8/src/_imaging.c#L1574-L1590

The code is handling for endianness for "I;16B", but not "I;16N" on a big-endian machine.

Yay295 avatar Jun 12 '23 19:06 Yay295

a test that helper.hopper() works for all image modes

Why would we need to test that this runs without error for all image modes? hopper() isn't part of Pillow, just the test suite. I don't see a need to start testing the tests.

radarhere avatar Jun 13 '23 08:06 radarhere

Yay295 force-pushed the bytes_tests branch

GitHub's suggestion auto-commit added an extra brace for some reason.

Why would we need to test that this runs without error for all image modes? hopper() isn't part of Pillow, just the test suite. I don't see a need to start testing the tests.

You're right. This will essentially be tested just by using it in other tests anyways.

Yay295 avatar Jun 13 '23 13:06 Yay295

rebased on main

Yay295 avatar Jul 02 '23 05:07 Yay295

Can this be merged?

Yay295 avatar Mar 20 '24 02:03 Yay295

I've created https://github.com/Yay295/Pillow/pull/13 with some suggestions.

radarhere avatar Mar 27 '24 03:03 radarhere

Thanks!

hugovk avatar Mar 30 '24 09:03 hugovk