diff --git a/Tests/helper.py b/Tests/helper.py index f42de8bb2..3cf51185b 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -92,23 +92,12 @@ class PillowTestCase(unittest.TestCase): a.size, b.size, msg or "got size %r, expected %r" % (a.size, b.size)) - diff = 0 - try: - ord(b'0') - for abyte, bbyte in zip(a.tobytes(), b.tobytes()): - diff += abs(ord(abyte)-ord(bbyte)) - except: - for abyte, bbyte in zip(a.tobytes(), b.tobytes()): - diff += abs(abyte-bbyte) - a, b = convert_to_comparable(a, b) - new_diff = 0 + diff = 0 for ach, bch in zip(a.split(), b.split()): chdiff = ImageMath.eval("abs(a - b)", a=ach, b=bch).convert('L') - new_diff += sum(i * num for i, num in enumerate(chdiff.histogram())) - - self.assertEqual(diff, new_diff) + diff += sum(i * num for i, num in enumerate(chdiff.histogram())) ave_diff = float(diff)/(a.size[0]*a.size[1]) self.assertGreaterEqual( diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index e1a3e0af5..136590667 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -205,7 +205,7 @@ class TestImageCms(PillowTestCase): target = Image.open('Tests/images/hopper.Lab.tif') - self.assert_image_similar(i, target, 30) + self.assert_image_similar(i, target, 3.5) def test_lab_srgb(self): psRGB = ImageCms.createProfile("sRGB") @@ -326,12 +326,12 @@ class TestImageCms(PillowTestCase): prepatch, these would segfault, postpatch they should emit a typeerror """ - + with self.assertRaises(TypeError): ImageCms.ImageCmsProfile(0).tobytes() with self.assertRaises(TypeError): ImageCms.ImageCmsProfile(1).tobytes() - + if __name__ == '__main__': unittest.main()