Merge pull request #1469 from hugovk/947fix

Make tests more robust
This commit is contained in:
wiredfool 2015-10-05 01:40:54 -07:00
commit f40547243e

View File

@ -76,7 +76,8 @@ class TestNumpy(PillowTestCase):
self.assert_image(Image.fromarray(a[:, :, 1]), "L", (10, 10)) self.assert_image(Image.fromarray(a[:, :, 1]), "L", (10, 10))
def _test_img_equals_nparray(self, img, np): def _test_img_equals_nparray(self, img, np):
self.assertEqual(img.size, np.shape[0:2]) np_size = np.shape[1], np.shape[0]
self.assertEqual(img.size, np_size)
px = img.load() px = img.load()
for x in range(0, img.size[0], int(img.size[0]/10)): for x in range(0, img.size[0], int(img.size[0]/10)):
for y in range(0, img.size[1], int(img.size[1]/10)): for y in range(0, img.size[1], int(img.size[1]/10)):
@ -92,6 +93,11 @@ class TestNumpy(PillowTestCase):
def _to_array(mode, dtype): def _to_array(mode, dtype):
img = hopper(mode) img = hopper(mode)
# Resize to non-square
img = img.crop((3, 0, 124, 127))
self.assertEqual(img.size, (121, 127))
np_img = numpy.array(img) np_img = numpy.array(img)
self._test_img_equals_nparray(img, np_img) self._test_img_equals_nparray(img, np_img)
self.assertEqual(np_img.dtype, numpy.dtype(dtype)) self.assertEqual(np_img.dtype, numpy.dtype(dtype))