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

Test failure: TestFilePng.test_save_p_transparent_black #3243

Closed
DerDakon opened this issue Jul 7, 2018 · 14 comments
Closed

Test failure: TestFilePng.test_save_p_transparent_black #3243

DerDakon opened this issue Jul 7, 2018 · 14 comments
Labels
Big-endian Big-endian processors Linux Platform A catchall for platform-related Testing
Projects

Comments

@DerDakon
Copy link
Contributor

DerDakon commented Jul 7, 2018

When I run the testsuite on my Gentoo HPPA (big endian!) machine, I get this:

platform linux2 -- Python 2.7.14, pytest-3.2.2, py-1.4.34, pluggy-0.4.0 -- /usr/bin/python2.7
cachedir: .cache
rootdir: /var/tmp/portage/dev-python/pillow-5.2.0/work/Pillow-5.2.0, inifile: setup.cfg
plugins: expect-1.1.0, cov-2.3.1, hypothesis-3.6.0
collecting ... collected 2352 items

[…]
self = <test_file_png.TestFilePng testMethod=test_save_p_transparent_black>

    def test_save_p_transparent_black(self):
        # check if solid black image with full transparency
        # is supported (check for #1838)
        im = Image.new("RGBA", (10, 10), (0, 0, 0, 0))
        self.assertEqual(im.getcolors(), [(100, (0, 0, 0, 0))])
    
        im = im.convert("P")
        test_file = self.tempfile("temp.png")
        im.save(test_file)
    
        # check if saved image contains same transparency
        im = Image.open(test_file)
>       self.assertEqual(len(im.info["transparency"]), 256)
E       TypeError: object of type 'int' has no len()

This can be traced back to at least 3.4.2, as reported in this downstream bug. After fixing the SIGBUS errors on 4.3.0 I had the same problem on sparc, so it may be a big endian issue.

@radarhere
Copy link
Member

radarhere commented Jul 19, 2018

If it helps, I was able to pass test_file_png tests in 64-bit Gentoo in Python 2.7.

@radarhere radarhere added the Linux label Jan 1, 2019
@aclark4life aclark4life added the Platform A catchall for platform-related label May 11, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to Icebox in Pillow May 11, 2019
@hugovk hugovk added the Big-endian Big-endian processors label Dec 18, 2019
@jiangtao9999
Copy link

jiangtao9999 commented Dec 30, 2019

Mips64el (little endian) is same.
I am compiling opensuse 15.1 to mips64el r2 .
python-Pillow version is 5.0.0 .

[  192s] =================================== FAILURES ===================================
[  192s] __________________ TestFilePng.test_save_p_transparent_black ___________________
[  192s] 
[  192s] self = <test_file_png.TestFilePng testMethod=test_save_p_transparent_black>
[  192s] 
[  192s]     def test_save_p_transparent_black(self):
[  192s]         # check if solid black image with full transparency
[  192s]         # is supported (check for #1838)
[  192s]         im = Image.new("RGBA", (10, 10), (0, 0, 0, 0))
[  192s]         self.assertEqual(im.getcolors(), [(100, (0, 0, 0, 0))])
[  192s]     
[  192s]         im = im.convert("P")
[  192s]         test_file = self.tempfile("temp.png")
[  192s]         im.save(test_file)
[  192s]     
[  192s]         # check if saved image contains same transparency
[  192s]         im = Image.open(test_file)
[  192s] >       self.assertEqual(len(im.info["transparency"]), 256)
[  192s] E       TypeError: object of type 'int' has no len()
[  192s] 
[  192s] Tests/test_file_png.py:287: TypeError

Maybe, is it a python bug ?
ctype modules? I remember that python is check failed at ctype.

@radarhere
Copy link
Member

Interestingly, big endian is now part of our CI jobs (#4336), and this test passes.

@DerDakon
Copy link
Contributor Author

This is what I get with 7.0.0 on Gentoo Sparc:

_________________________________________________________________________________________________________________ TestFileLibTiff.test_old_style_jpeg __________________________________________________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff testMethod=test_old_style_jpeg>

    def test_old_style_jpeg(self):
        infile = "Tests/images/old-style-jpeg-compression.tif"
        with Image.open(infile) as im:
            self.assert_image_equal_tofile(
>               im, "Tests/images/old-style-jpeg-compression.png"
            )

Tests/test_file_libtiff.py:806:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:124: in assert_image_equal_tofile
    self.assert_image_equal(a, img, msg)
Tests/helper.py:118: in assert_image_equal
    self.fail(msg or "got different content")
E   AssertionError: got different content
__________________________________________________________________________________________________________ TestFileLibTiff.test_strip_ycbcr_jpeg_1x1_sampling __________________________________________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff testMethod=test_strip_ycbcr_jpeg_1x1_sampling>

    def test_strip_ycbcr_jpeg_1x1_sampling(self):
        infile = "Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif"
        with Image.open(infile) as im:
>           self.assert_image_equal_tofile(im, "Tests/images/flower2.jpg")

Tests/test_file_libtiff.py:783:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:124: in assert_image_equal_tofile
    self.assert_image_equal(a, img, msg)
Tests/helper.py:118: in assert_image_equal
    self.fail(msg or "got different content")
E   AssertionError: got different content
__________________________________________________________________________________________________________ TestFileLibTiff.test_strip_ycbcr_jpeg_2x2_sampling __________________________________________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff testMethod=test_strip_ycbcr_jpeg_2x2_sampling>

    def test_strip_ycbcr_jpeg_2x2_sampling(self):
        infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif"
        with Image.open(infile) as im:
>           self.assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

Tests/test_file_libtiff.py:778:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:164: in assert_image_similar_tofile
    self.assert_image_similar(a, img, epsilon, msg)
Tests/helper.py:158: in assert_image_similar
    raise e
Tests/helper.py:149: in assert_image_similar
    % (ave_diff, epsilon),
E   AssertionError: 0.5 not greater than or equal to 214.47257523148147 :  average pixel value difference 214.4726 > epsilon 0.5000
__________________________________________________________________________________________________________ TestFileLibTiff.test_tiled_ycbcr_jpeg_1x1_sampling __________________________________________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff testMethod=test_tiled_ycbcr_jpeg_1x1_sampling>

    def test_tiled_ycbcr_jpeg_1x1_sampling(self):
        infile = "Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif"
        with Image.open(infile) as im:
>           self.assert_image_equal_tofile(im, "Tests/images/flower2.jpg")

Tests/test_file_libtiff.py:795:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:124: in assert_image_equal_tofile
    self.assert_image_equal(a, img, msg)
Tests/helper.py:118: in assert_image_equal
    self.fail(msg or "got different content")
E   AssertionError: got different content
__________________________________________________________________________________________________________ TestFileLibTiff.test_tiled_ycbcr_jpeg_2x2_sampling __________________________________________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff testMethod=test_tiled_ycbcr_jpeg_2x2_sampling>

    def test_tiled_ycbcr_jpeg_2x2_sampling(self):
        infile = "Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif"
        with Image.open(infile) as im:
>           self.assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

Tests/test_file_libtiff.py:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:164: in assert_image_similar_tofile
    self.assert_image_similar(a, img, epsilon, msg)
Tests/helper.py:158: in assert_image_similar
    raise e
Tests/helper.py:149: in assert_image_similar
    % (ave_diff, epsilon),
E   AssertionError: 0.5 not greater than or equal to 214.44628472222223 :  average pixel value difference 214.4463 > epsilon 0.5000
_______________________________________________________________________________________________________________________ TestFilePng.test_sanity ________________________________________________________________________________________________________________________

self = <Tests.test_file_png.TestFilePng testMethod=test_sanity>

    def test_sanity(self):

        # internal version number
        self.assertRegex(Image.core.zlib_version, r"\d+\.\d+\.\d+(\.\d+)?$")

        test_file = self.tempfile("temp.png")

        hopper("RGB").save(test_file)

        with Image.open(test_file) as im:
            im.load()
            self.assertEqual(im.mode, "RGB")
            self.assertEqual(im.size, (128, 128))
            self.assertEqual(im.format, "PNG")
            self.assertEqual(im.get_format_mimetype(), "image/png")

        for mode in ["1", "L", "P", "RGB", "I", "I;16"]:
            im = hopper(mode)
            im.save(test_file)
            with Image.open(test_file) as reloaded:
                if mode == "I;16":
                    reloaded = reloaded.convert(mode)
>               self.assert_image_equal(reloaded, im)

Tests/test_file_png.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:118: in assert_image_equal
    self.fail(msg or "got different content")
E   AssertionError: got different content
___________________________________________________________________________________________________________________ TestImageGetExtrema.test_extrema ___________________________________________________________________________________________________________________

self = <Tests.test_image_getextrema.TestImageGetExtrema testMethod=test_extrema>

    def test_extrema(self):
        def extrema(mode):
            return hopper(mode).getextrema()

        self.assertEqual(extrema("1"), (0, 255))
        self.assertEqual(extrema("L"), (1, 255))
        self.assertEqual(extrema("I"), (1, 255))
        self.assertEqual(extrema("F"), (1, 255))
        self.assertEqual(extrema("P"), (0, 225))  # fixed palette
        self.assertEqual(extrema("RGB"), ((0, 255), (0, 255), (0, 255)))
        self.assertEqual(extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255)))
        self.assertEqual(extrema("CMYK"), ((0, 255), (0, 255), (0, 255), (0, 0)))
>       self.assertEqual(extrema("I;16"), (1, 255))
E       AssertionError: Tuples differ: (256, 65280) != (1, 255)
E
E       First differing element 0:
E       256
E       1  
E
E       - (256, 65280)
E       + (1, 255)

Tests/test_image_getextrema.py:19: AssertionError
___________________________________________________________________________________________________________________ TestImageGetExtrema.test_true_16 ___________________________________________________________________________________________________________________

self = <Tests.test_image_getextrema.TestImageGetExtrema testMethod=test_true_16>

    def test_true_16(self):
        with Image.open("Tests/images/16_bit_noise.tif") as im:
            self.assertEqual(im.mode, "I;16")
            extrema = im.getextrema()
>       self.assertEqual(extrema, (106, 285))
E       AssertionError: Tuples differ: (513, 64512) != (106, 285)
E
E       First differing element 0:
E       513
E       106
E
E       - (513, 64512)
E       + (106, 285)

Tests/test_image_getextrema.py:25: AssertionError

@thesamesam
Copy link

Failures on ppc64 (big endian), Gentoo:

===================================================================================== FAILURES ======================================================================================
________________________________________________________________ TestFileLibTiff.test_strip_ycbcr_jpeg_2x2_sampling _________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff object at 0xf39f8ef0>

    def test_strip_ycbcr_jpeg_2x2_sampling(self):
        infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif"
        with Image.open(infile) as im:
>           assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

Tests/test_file_libtiff.py:768:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:147: in assert_image_similar_tofile
    assert_image_similar(a, img, epsilon, msg)
Tests/helper.py:140: in assert_image_similar
    raise e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=480x360 at 0xF369AB70>, b = <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=480x360 at 0xF368EF30>, epsilon = 0.5
msg = None

    def assert_image_similar(a, b, epsilon, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )

        a, b = convert_to_comparable(a, b)

        diff = 0
        for ach, bch in zip(a.split(), b.split()):
            chdiff = ImageMath.eval("abs(a - b)", a=ach, b=bch).convert("L")
            diff += sum(i * num for i, num in enumerate(chdiff.histogram()))

        ave_diff = diff / (a.size[0] * a.size[1])
        try:
>           assert epsilon >= ave_diff, (
                msg or ""
            ) + " average pixel value difference %.4f > epsilon %.4f" % (ave_diff, epsilon)
E           AssertionError:  average pixel value difference 214.4726 > epsilon 0.5000
E           assert 0.5 >= 214.47257523148147

Tests/helper.py:130: AssertionError
________________________________________________________________ TestFileLibTiff.test_strip_ycbcr_jpeg_1x1_sampling _________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff object at 0xf3b1c310>

    def test_strip_ycbcr_jpeg_1x1_sampling(self):
        infile = "Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif"
        with Image.open(infile) as im:
>           assert_image_equal_tofile(im, "Tests/images/flower2.jpg")

Tests/test_file_libtiff.py:773:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:110: in assert_image_equal_tofile
    assert_image_equal(a, img, msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=300x225 at 0xF3894B30>, b = <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=300x225 at 0xF38946F0>, msg = None

    def assert_image_equal(a, b, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )
        if a.tobytes() != b.tobytes():
            if HAS_UPLOADER:
                try:
                    url = test_image_results.upload(a, b)
                    logger.error("Url for test images: %s" % url)
                except Exception:
                    pass

>           assert False, msg or "got different content"
E           AssertionError: got different content
E           assert False

Tests/helper.py:103: AssertionError
________________________________________________________________ TestFileLibTiff.test_tiled_ycbcr_jpeg_1x1_sampling _________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff object at 0xf39f9b70>

    def test_tiled_ycbcr_jpeg_1x1_sampling(self):
        infile = "Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif"
        with Image.open(infile) as im:
>           assert_image_equal_tofile(im, "Tests/images/flower2.jpg")

Tests/test_file_libtiff.py:783:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:110: in assert_image_equal_tofile
    assert_image_equal(a, img, msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=300x225 at 0xF39F9AB0>, b = <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=300x225 at 0xF39F9DD0>, msg = None

    def assert_image_equal(a, b, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )
        if a.tobytes() != b.tobytes():
            if HAS_UPLOADER:
                try:
                    url = test_image_results.upload(a, b)
                    logger.error("Url for test images: %s" % url)
                except Exception:
                    pass

>           assert False, msg or "got different content"
E           AssertionError: got different content
E           assert False

Tests/helper.py:103: AssertionError
________________________________________________________________ TestFileLibTiff.test_tiled_ycbcr_jpeg_2x2_sampling _________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff object at 0xf3780870>

    def test_tiled_ycbcr_jpeg_2x2_sampling(self):
        infile = "Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif"
        with Image.open(infile) as im:
>           assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

Tests/test_file_libtiff.py:788:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:147: in assert_image_similar_tofile
    assert_image_similar(a, img, epsilon, msg)
Tests/helper.py:140: in assert_image_similar
    raise e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=480x360 at 0xF3780150>, b = <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=480x360 at 0xF37803B0>, epsilon = 0.5
msg = None

    def assert_image_similar(a, b, epsilon, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )

        a, b = convert_to_comparable(a, b)

        diff = 0
        for ach, bch in zip(a.split(), b.split()):
            chdiff = ImageMath.eval("abs(a - b)", a=ach, b=bch).convert("L")
            diff += sum(i * num for i, num in enumerate(chdiff.histogram()))

        ave_diff = diff / (a.size[0] * a.size[1])
        try:
>           assert epsilon >= ave_diff, (
                msg or ""
            ) + " average pixel value difference %.4f > epsilon %.4f" % (ave_diff, epsilon)
E           AssertionError:  average pixel value difference 214.4463 > epsilon 0.5000
E           assert 0.5 >= 214.44628472222223

Tests/helper.py:130: AssertionError
________________________________________________________________________ TestFileLibTiff.test_old_style_jpeg ________________________________________________________________________

self = <Tests.test_file_libtiff.TestFileLibTiff object at 0xf3959c90>

    def test_old_style_jpeg(self):
        infile = "Tests/images/old-style-jpeg-compression.tif"
        with Image.open(infile) as im:
>           assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")

Tests/test_file_libtiff.py:793:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Tests/helper.py:110: in assert_image_equal_tofile
    assert_image_equal(a, img, msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=4160x870 at 0xF3959850>, b = <PIL.PngImagePlugin.PngImageFile image mode=RGB size=4160x870 at 0xF3959630>, msg = None

    def assert_image_equal(a, b, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )
        if a.tobytes() != b.tobytes():
            if HAS_UPLOADER:
                try:
                    url = test_image_results.upload(a, b)
                    logger.error("Url for test images: %s" % url)
                except Exception:
                    pass

>           assert False, msg or "got different content"
E           AssertionError: got different content
E           assert False

Tests/helper.py:103: AssertionError
______________________________________________________________________________ TestFilePng.test_sanity ______________________________________________________________________________

self = <Tests.test_file_png.TestFilePng object at 0xf34e9810>, tmp_path = PosixPath('/var/tmp/portage/dev-python/pillow-7.1.2/temp/pytest-of-portage/pytest-0/test_sanity3')

    @pytest.mark.xfail(is_big_endian() and on_ci(), reason="Fails on big-endian")
    def test_sanity(self, tmp_path):

        # internal version number
        assert re.search(r"\d+\.\d+\.\d+(\.\d+)?$", Image.core.zlib_version)

        test_file = str(tmp_path / "temp.png")

        hopper("RGB").save(test_file)

        with Image.open(test_file) as im:
            im.load()
            assert im.mode == "RGB"
            assert im.size == (128, 128)
            assert im.format == "PNG"
            assert im.get_format_mimetype() == "image/png"

        for mode in ["1", "L", "P", "RGB", "I", "I;16"]:
            im = hopper(mode)
            im.save(test_file)
            with Image.open(test_file) as reloaded:
                if mode == "I;16":
                    reloaded = reloaded.convert(mode)
>               assert_image_equal(reloaded, im)

Tests/test_file_png.py:95:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = <PIL.Image.Image image mode=I;16 size=128x128 at 0xF34E9030>, b = <PIL.Image.Image image mode=I;16 size=128x128 at 0xF34E9F90>, msg = None

    def assert_image_equal(a, b, msg=None):
        assert a.mode == b.mode, msg or "got mode {!r}, expected {!r}".format(
            a.mode, b.mode
        )
        assert a.size == b.size, msg or "got size {!r}, expected {!r}".format(
            a.size, b.size
        )
        if a.tobytes() != b.tobytes():
            if HAS_UPLOADER:
                try:
                    url = test_image_results.upload(a, b)
                    logger.error("Url for test images: %s" % url)
                except Exception:
                    pass

>           assert False, msg or "got different content"
E           AssertionError: got different content
E           assert False

Tests/helper.py:103: AssertionError
[...]
================================================================ 6 failed, 1219 passed, 227 skipped in 57.27 seconds ================================================================
 * ERROR: dev-python/pillow-7.1.2::gentoo failed (test phase):
 *   Tests fail with python3.7

@DerDakon
Copy link
Contributor Author

DerDakon commented Sep 10, 2020

Updated error list for Pillow 7.2.0 on Gentoo/Sparc (tl;dr: the same as on ppc64 above):

platform linux -- Python 3.7.8, pytest-4.6.11, py-1.8.0, pluggy-0.13.1 -- /usr/bin/python3.7

XFAIL Tests/test_file_palm.py::test_p_mode
  Palm P image is wrong
XFAIL Tests/test_image_resample.py::TestCoreResampleAlphaCorrect::test_levels_rgba
  Current implementation isn't precise enough
XFAIL Tests/test_image_resample.py::TestCoreResampleAlphaCorrect::test_levels_la
  Current implementation isn't precise enough
FAILED Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_2x2_sampling - AssertionError:  average pixel value difference 214.4726 > epsilon 0.5000
FAILED Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_1x1_sampling - AssertionError: got different content
FAILED Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_1x1_sampling - AssertionError: got different content
FAILED Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_2x2_sampling - AssertionError:  average pixel value difference 214.4463 > epsilon 0.5000
FAILED Tests/test_file_libtiff.py::TestFileLibTiff::test_old_style_jpeg - AssertionError: got different content
FAILED Tests/test_file_png.py::TestFilePng::test_sanity - AssertionError: got different content

@DerDakon
Copy link
Contributor Author

I get exactly the same test failures on hppa with 7.2.0 as on sparc, with the same value differences.

@radarhere
Copy link
Member

@DerDakon why isn't the test_save_p_transparent_black failure mentioned in #3927?

@DerDakon
Copy link
Contributor Author

Because it magically passes there. Found it passing in the logs of 6.2.1, 6.2.2, 7.2.0, and 8.0.1.

@radarhere
Copy link
Member

I expect the failures listed in #3243 (comment), #3243 (comment) and #3243 (comment) to now be passing on main (thanks to #5364, #5901 and #4457), leaving just test_save_p_transparent_black.

@radarhere
Copy link
Member

radarhere commented Dec 28, 2021

If @DerDakon is saying that test_save_p_transparent_black was fixed by something between 5.1.0 and 6.2.1, then this looks ready to be closed (or you can wait a few days and test when Pillow 9.0 is released, due on January 2).

@radarhere
Copy link
Member

If the test_save_p_transparent_black problem is purely a big endian issue, then I'm unable to reproduce it with Pillow 5.1.0 - radarhere/docker-images@50f2964 passes in https://github.com/radarhere/docker-images/runs/4679158046

@radarhere
Copy link
Member

Pillow 9.0 has been released. So everything except for test_save_p_transparent_black should now be passing.

@DerDakon
Copy link
Contributor Author

On hppa all tests pass. On sparc I had only one unrelated error:

Tests/test_file_eps.py::test_timeout[Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps] - Failed: Timeout >5.0s

Can be hard to meet such short timing requirements if it involves disk I/O, e.g. for start of external programs.

Pillow automation moved this from Icebox to Closed Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Big-endian Big-endian processors Linux Platform A catchall for platform-related Testing
Projects
Pillow
  
Closed
Development

No branches or pull requests

6 participants