Merge pull request #2961 from radarhere/assert

Changed assert statements to unittest calls
This commit is contained in:
wiredfool 2018-01-24 10:54:18 +00:00 committed by GitHub
commit d04380afb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -119,7 +119,7 @@ class TestFileJpeg(PillowTestCase):
# using a 4-byte test code should allow us to detect out of # using a 4-byte test code should allow us to detect out of
# order issues. # order issues.
icc_profile = (b"Test"*int(n/4+1))[:n] icc_profile = (b"Test"*int(n/4+1))[:n]
assert len(icc_profile) == n # sanity self.assertEqual(len(icc_profile), n) # sanity
im1 = self.roundtrip(hopper(), icc_profile=icc_profile) im1 = self.roundtrip(hopper(), icc_profile=icc_profile)
self.assertEqual(im1.info.get("icc_profile"), icc_profile or None) self.assertEqual(im1.info.get("icc_profile"), icc_profile or None)
test(0) test(0)

View File

@ -27,14 +27,14 @@ class TestImageQuantize(PillowTestCase):
raise raise
self.assert_image(converted, 'P', converted.size) self.assert_image(converted, 'P', converted.size)
self.assert_image_similar(converted.convert('RGB'), image, 15) self.assert_image_similar(converted.convert('RGB'), image, 15)
assert len(converted.getcolors()) == 100 self.assertEqual(len(converted.getcolors()), 100)
def test_octree_quantize(self): def test_octree_quantize(self):
image = hopper() image = hopper()
converted = image.quantize(100, Image.FASTOCTREE) converted = image.quantize(100, Image.FASTOCTREE)
self.assert_image(converted, 'P', converted.size) self.assert_image(converted, 'P', converted.size)
self.assert_image_similar(converted.convert('RGB'), image, 20) self.assert_image_similar(converted.convert('RGB'), image, 20)
assert len(converted.getcolors()) == 100 self.assertEqual(len(converted.getcolors()), 100)
def test_rgba_quantize(self): def test_rgba_quantize(self):
image = hopper('RGBA') image = hopper('RGBA')

View File

@ -422,7 +422,7 @@ class CoreResampleBoxTest(PillowTestCase):
def test_tiles(self): def test_tiles(self):
im = Image.open("Tests/images/flower.jpg") im = Image.open("Tests/images/flower.jpg")
assert im.size == (480, 360) self.assertEqual(im.size, (480, 360))
dst_size = (251, 188) dst_size = (251, 188)
reference = im.resize(dst_size, Image.BICUBIC) reference = im.resize(dst_size, Image.BICUBIC)
@ -434,7 +434,7 @@ class CoreResampleBoxTest(PillowTestCase):
# This test shows advantages of the subpixel resizing # This test shows advantages of the subpixel resizing
# after supersampling (e.g. during JPEG decoding). # after supersampling (e.g. during JPEG decoding).
im = Image.open("Tests/images/flower.jpg") im = Image.open("Tests/images/flower.jpg")
assert im.size == (480, 360) self.assertEqual(im.size, (480, 360))
dst_size = (48, 36) dst_size = (48, 36)
# Reference is cropped image resized to destination # Reference is cropped image resized to destination
reference = im.crop((0, 0, 473, 353)).resize(dst_size, Image.BICUBIC) reference = im.crop((0, 0, 473, 353)).resize(dst_size, Image.BICUBIC)