Refactor and test matrix convert with RGB and L modes

This commit is contained in:
hugovk 2017-01-29 14:24:49 +02:00
parent cea36587ab
commit 90dac5f4dc

View File

@ -150,7 +150,9 @@ class TestImageConvert(PillowTestCase):
self.assertRaises(ValueError, self.assertRaises(ValueError,
lambda: im.convert(mode='CMYK', matrix=matrix)) lambda: im.convert(mode='CMYK', matrix=matrix))
def test_matrix(self): def test_matrix_rgb(self):
def matrix_convert(mode):
# Arrange # Arrange
im = hopper('RGB') im = hopper('RGB')
matrix = ( matrix = (
@ -161,12 +163,14 @@ class TestImageConvert(PillowTestCase):
# Act # Act
# Convert an RGB image to the CIE XYZ colour space # Convert an RGB image to the CIE XYZ colour space
converted_im = im.convert(mode='RGB', matrix=matrix) converted_im = im.convert(mode=mode, matrix=matrix)
# Assert # Assert
self.assertEqual(converted_im.mode, 'RGB') self.assertEqual(converted_im.mode, mode)
self.assertEqual(converted_im.size, im.size) self.assertEqual(converted_im.size, im.size)
matrix_convert('RGB')
matrix_convert('L')
if __name__ == '__main__': if __name__ == '__main__':