Use more specific assertions

This commit is contained in:
Hugo 2018-08-04 21:08:40 +03:00
parent 901c1e2aea
commit d1ca4916e0
4 changed files with 6 additions and 6 deletions

View File

@ -187,10 +187,10 @@ class PillowTestCase(unittest.TestCase):
return result
def assert_all_same(self, items, msg=None):
self.assertTrue(items.count(items[0]) == len(items), msg)
self.assertEqual(items.count(items[0]), len(items), msg)
def assert_not_all_same(self, items, msg=None):
self.assertFalse(items.count(items[0]) == len(items), msg)
self.assertNotEqual(items.count(items[0]), len(items), msg)
def assert_tuple_approx_equal(self, actuals, targets, threshold, msg):
"""Tests if actuals has values within threshold from targets"""

View File

@ -545,11 +545,11 @@ class TestFileLibTiff(LibTiffTestCase):
def test_read_icc(self):
with Image.open("Tests/images/hopper.iccprofile.tif") as img:
icc = img.info.get('icc_profile')
self.assertNotEqual(icc, None)
self.assertIsNotNone(icc)
TiffImagePlugin.READ_LIBTIFF = True
with Image.open("Tests/images/hopper.iccprofile.tif") as img:
icc_libtiff = img.info.get('icc_profile')
self.assertNotEqual(icc_libtiff, None)
self.assertIsNotNone(icc_libtiff)
TiffImagePlugin.READ_LIBTIFF = False
self.assertEqual(icc, icc_libtiff)

View File

@ -516,7 +516,7 @@ class TestImage(PillowTestCase):
self.assertEqual(new_im.palette.tobytes(),
palette_result.tobytes())
else:
self.assertEqual(new_im.palette, None)
self.assertIsNone(new_im.palette)
_make_new(im, im_p, im_p.palette)
_make_new(im_p, im, None)

View File

@ -88,7 +88,7 @@ class TestImageConvert(PillowTestCase):
# Assert
self.assertNotIn('transparency', im_rgba.info)
# https://github.com/python-pillow/Pillow/issues/2702
self.assertEqual(im_rgba.palette, None)
self.assertIsNone(im_rgba.palette)
def test_trns_l(self):
im = hopper('L')