diff --git a/Tests/test_features.py b/Tests/test_features.py index 6644ec012..d7e505ac7 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -76,11 +76,13 @@ class TestFeatures(PillowTestCase): self.assertEqual(lines[5], "-" * 68) self.assertTrue(lines[6].startswith("Python ")) jpeg = ( - "\n" + - "-" * 68 + "\n" + - "JPEG image/jpeg\n" + - "Extensions: .jfif, .jpe, .jpeg, .jpg\n" + - "Features: open, save\n" + - "-" * 68 + "\n" + "\n" + + "-" * 68 + + "\n" + + "JPEG image/jpeg\n" + + "Extensions: .jfif, .jpe, .jpeg, .jpg\n" + + "Features: open, save\n" + + "-" * 68 + + "\n" ) self.assertIn(jpeg, out) diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 2c2da8483..3388c2055 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -593,7 +593,7 @@ class TestImageFont(PillowTestCase): font = self.get_font() freetype = distutils.version.StrictVersion(ImageFont.core.freetype2_version) - if freetype < '2.9.1': + if freetype < "2.9.1": self.assertRaises(NotImplementedError, font.get_variation_names) self.assertRaises(NotImplementedError, font.get_variation_axes) return @@ -604,27 +604,58 @@ class TestImageFont(PillowTestCase): font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf") self.assertEqual( font.get_variation_names(), - [b'ExtraLight', b'Light', b'Regular', b'Semibold', b'Bold', - b'Black', b'Black Medium Contrast', b'Black High Contrast', b'Default']) + [ + b"ExtraLight", + b"Light", + b"Regular", + b"Semibold", + b"Bold", + b"Black", + b"Black Medium Contrast", + b"Black High Contrast", + b"Default", + ], + ) self.assertEqual( font.get_variation_axes(), - [{'name': b'Weight', 'minimum': 200, 'maximum': 900, 'default': 389}, - {'name': b'Contrast', 'minimum': 0, 'maximum': 100, 'default': 0}]) + [ + {"name": b"Weight", "minimum": 200, "maximum": 900, "default": 389}, + {"name": b"Contrast", "minimum": 0, "maximum": 100, "default": 0}, + ], + ) font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf") self.assertEqual( font.get_variation_names(), - [b'20', b'40', b'60', b'80', b'100', b'120', b'140', b'160', b'180', - b'200', b'220', b'240', b'260', b'280', b'300', b'Regular']) + [ + b"20", + b"40", + b"60", + b"80", + b"100", + b"120", + b"140", + b"160", + b"180", + b"200", + b"220", + b"240", + b"260", + b"280", + b"300", + b"Regular", + ], + ) self.assertEqual( font.get_variation_axes(), - [{'name': b'Size', 'minimum': 0, 'maximum': 300, 'default': 0}]) + [{"name": b"Size", "minimum": 0, "maximum": 300, "default": 0}], + ) def test_variation_set_by_name(self): font = self.get_font() freetype = distutils.version.StrictVersion(ImageFont.core.freetype2_version) - if freetype < '2.9.1': + if freetype < "2.9.1": self.assertRaises(NotImplementedError, font.set_variation_by_name, "Bold") return @@ -637,6 +668,7 @@ class TestImageFont(PillowTestCase): expected = Image.open(path) self.assert_image_similar(im, expected, epsilon) + font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) _check_text(font, "Tests/images/variation_adobe.png", 11) for name in ["Bold", b"Bold"]: @@ -653,7 +685,7 @@ class TestImageFont(PillowTestCase): font = self.get_font() freetype = distutils.version.StrictVersion(ImageFont.core.freetype2_version) - if freetype < '2.9.1': + if freetype < "2.9.1": self.assertRaises(NotImplementedError, font.set_variation_by_axes, [100]) return @@ -666,6 +698,7 @@ class TestImageFont(PillowTestCase): expected = Image.open(path) self.assert_image_similar(im, expected, epsilon) + font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) font.set_variation_by_axes([500, 50]) _check_text(font, "Tests/images/variation_adobe_axes.png", 5.1) diff --git a/Tests/test_imagefontctl.py b/Tests/test_imagefontctl.py index 16d73def5..3ec5e9055 100644 --- a/Tests/test_imagefontctl.py +++ b/Tests/test_imagefontctl.py @@ -162,14 +162,14 @@ class TestImagecomplextext(PillowTestCase): def test_x_max_and_y_offset(self): ttf = ImageFont.truetype("Tests/fonts/ArefRuqaa-Regular.ttf", 40) - im = Image.new(mode='RGB', size=(50, 100)) + im = Image.new(mode="RGB", size=(50, 100)) draw = ImageDraw.Draw(im) - draw.text((0, 0), 'لح', font=ttf, fill=500) + draw.text((0, 0), "لح", font=ttf, fill=500) - target = 'Tests/images/test_x_max_and_y_offset.png' + target = "Tests/images/test_x_max_and_y_offset.png" target_img = Image.open(target) - self.assert_image_similar(im, target_img, .5) + self.assert_image_similar(im, target_img, 0.5) def test_language(self): ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE) diff --git a/Tests/test_main.py b/Tests/test_main.py index c9445ce9c..847def834 100644 --- a/Tests/test_main.py +++ b/Tests/test_main.py @@ -18,11 +18,16 @@ class TestMain(TestCase): self.assertEqual(lines[5], "-" * 68) self.assertTrue(lines[6].startswith("Python ")) jpeg = ( - os.linesep + - "-" * 68 + os.linesep + - "JPEG image/jpeg" + os.linesep + - "Extensions: .jfif, .jpe, .jpeg, .jpg" + os.linesep + - "Features: open, save" + os.linesep + - "-" * 68 + os.linesep + os.linesep + + "-" * 68 + + os.linesep + + "JPEG image/jpeg" + + os.linesep + + "Extensions: .jfif, .jpe, .jpeg, .jpg" + + os.linesep + + "Features: open, save" + + os.linesep + + "-" * 68 + + os.linesep ) self.assertIn(jpeg, out)