From 30abb42c27e2522878c099d0f85b61c206cc7c71 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 25 Aug 2016 03:22:20 -0700 Subject: [PATCH] More specific version of pr #2083 --- Tests/test_numpy.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 96b0f4371..1a44d3c8b 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -15,8 +15,13 @@ except ImportError: TEST_IMAGE_SIZE = (10, 10) -@unittest.skipIf(hasattr(sys, 'pypy_version_info'), - "numpy is flaky on PyPy") +# Numpy on pypy as of pypy 5.3.1 is corrupting the numpy.array(Image) +# call such that it's returning a object of type numpy.ndarray, but +# the repr is that of a PIL.Image. Size and shape are 1 and (), not the +# size and shape of the array. This causes failures in several tests. +SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and ( + sys.pypy_version_info <= (5,3,1,'final',0)) + class TestNumpy(PillowTestCase): def setUp(self): @@ -115,6 +120,7 @@ class TestNumpy(PillowTestCase): for y in range(0, img.size[1], int(img.size[1]/10)): self.assert_deep_equal(px[x, y], np[y, x]) + @unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy") def test_16bit(self): img = Image.open('Tests/images/16bit.cropped.tif') np_img = numpy.array(img) @@ -136,6 +142,7 @@ class TestNumpy(PillowTestCase): im_good = Image.open(filename) self.assert_image_equal(im_good, im_test) + @unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy") def test_to_array(self): def _to_array(mode, dtype):