From fbb6cae7853cd48e0f70d7e289645510c41e247f Mon Sep 17 00:00:00 2001 From: Pierrick Koch Date: Wed, 27 Apr 2016 16:23:22 +0200 Subject: [PATCH] [Test] fix Image.fromarray LA mode test AppVeyor: ERROR: Failure: ImportError (No module named numpy) inspired from: Tests/test_numpy.py --- Tests/test_image_fromarray_la.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Tests/test_image_fromarray_la.py b/Tests/test_image_fromarray_la.py index 15931b16d..fa1e81e7c 100644 --- a/Tests/test_image_fromarray_la.py +++ b/Tests/test_image_fromarray_la.py @@ -2,18 +2,28 @@ from helper import unittest, PillowTestCase from PIL import Image -import numpy as np +try: + import site + import numpy +except ImportError: + # Skip via setUp() + pass class TestImageFromArrayLA(PillowTestCase): - def test_sanity(self): - ar1 = (np.random.random((40,40,2))*255).astype('uint8') - im1 = Image.fromarray(ar1) - arr = np.array(im1.getdata(), 'uint8') - ar2 = arr.reshape(im1.size[1], im1.size[0], arr.shape[1]) - im2 = Image.fromarray(ar2) + def setUp(self): + try: + import site + import numpy + except ImportError: + self.skipTest("ImportError") - self.assert_image_equal(im1, im2) + def test_sanity(self): + ar1 = (numpy.random.random((40,40,2))*255).astype('uint8') + im1 = Image.fromarray(ar1) + arr = numpy.array(im1.getdata(), 'uint8') + ar2 = arr.reshape(im1.size[1], im1.size[0], arr.shape[1]) + self.assertTrue(numpy.array_equal(ar1, ar2)) if __name__ == '__main__':