updated test to assert equality with reference images

This commit is contained in:
tsennott 2018-07-07 02:40:25 -07:00
parent b19c460568
commit 837d868333
4 changed files with 15 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

View File

@ -1,6 +1,7 @@
from helper import unittest, PillowTestCase, hopper from helper import unittest, PillowTestCase, hopper
from PIL import ImageOps from PIL import ImageOps
from PIL import Image
class TestImageOps(PillowTestCase): class TestImageOps(PillowTestCase):
@ -97,18 +98,23 @@ class TestImageOps(PillowTestCase):
def test_colorize(self): def test_colorize(self):
# Test the colorizing function # Test the colorizing function
# Grab test image # Grab test image (10px black, 256px gradient, 10px white)
i = hopper("L").resize((15, 16)) im = Image.open("Tests/images/bw_gradient.png")
im = im.convert("L")
# Test original 2-color functionality # Test original 2-color functionality
ImageOps.colorize(i, 'green', 'red') out_2color = ImageOps.colorize(im, 'red', 'green')
# Test new three color functionality (cyanotype colors) # Test new three color functionality, with midpoint offset
ImageOps.colorize(i, out_3color = ImageOps.colorize(im, 'red', 'green', 'yellow', 100)
(32, 37, 79),
(255, 255, 255), # Assert 2-color
(35, 52, 121), ref_2color = Image.open("Tests/images/bw_gradient_2color.png")
40) self.assert_image_equal(out_2color, ref_2color)
# Assert 3-color
ref_3color = Image.open("Tests/images/bw_gradient_3color.png")
self.assert_image_equal(out_3color, ref_3color)
if __name__ == '__main__': if __name__ == '__main__':