From 90dac5f4dc529bc60e94b387960dd0b5546eaa19 Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 29 Jan 2017 14:24:49 +0200 Subject: [PATCH] Refactor and test matrix convert with RGB and L modes --- Tests/test_image_convert.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 6128dc9d9..170b174ad 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -150,23 +150,27 @@ class TestImageConvert(PillowTestCase): self.assertRaises(ValueError, lambda: im.convert(mode='CMYK', matrix=matrix)) - def test_matrix(self): - # Arrange - im = hopper('RGB') - matrix = ( - 0.412453, 0.357580, 0.180423, 0, - 0.212671, 0.715160, 0.072169, 0, - 0.019334, 0.119193, 0.950227, 0) - self.assertEqual(im.mode, 'RGB') + def test_matrix_rgb(self): - # Act - # Convert an RGB image to the CIE XYZ colour space - converted_im = im.convert(mode='RGB', matrix=matrix) + def matrix_convert(mode): + # Arrange + im = hopper('RGB') + matrix = ( + 0.412453, 0.357580, 0.180423, 0, + 0.212671, 0.715160, 0.072169, 0, + 0.019334, 0.119193, 0.950227, 0) + self.assertEqual(im.mode, 'RGB') - # Assert - self.assertEqual(converted_im.mode, 'RGB') - self.assertEqual(converted_im.size, im.size) + # Act + # Convert an RGB image to the CIE XYZ colour space + converted_im = im.convert(mode=mode, matrix=matrix) + # Assert + self.assertEqual(converted_im.mode, mode) + self.assertEqual(converted_im.size, im.size) + + matrix_convert('RGB') + matrix_convert('L') if __name__ == '__main__':