Skip to content

Commit

Permalink
Merge pull request #3914 from radarhere/black
Browse files Browse the repository at this point in the history
Fixed black formatting
  • Loading branch information
radarhere committed Jun 22, 2019
2 parents c1b3adb + 68fac40 commit 32d1050
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 26 deletions.
14 changes: 8 additions & 6 deletions Tests/test_features.py
Expand Up @@ -76,11 +76,13 @@ def test_pilinfo(self):
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)
53 changes: 43 additions & 10 deletions Tests/test_imagefont.py
Expand Up @@ -593,7 +593,7 @@ def test_variation_get(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.get_variation_names)
self.assertRaises(NotImplementedError, font.get_variation_axes)
return
Expand All @@ -604,27 +604,58 @@ def test_variation_get(self):
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

Expand All @@ -637,6 +668,7 @@ def _check_text(font, path, epsilon):

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"]:
Expand All @@ -653,7 +685,7 @@ def test_variation_set_by_axes(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_axes, [100])
return

Expand All @@ -666,6 +698,7 @@ def _check_text(font, path, epsilon):

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)
Expand Down
8 changes: 4 additions & 4 deletions Tests/test_imagefontctl.py
Expand Up @@ -162,14 +162,14 @@ def test_arabictext_features(self):
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)
Expand Down
17 changes: 11 additions & 6 deletions Tests/test_main.py
Expand Up @@ -18,11 +18,16 @@ def test_main(self):
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)

0 comments on commit 32d1050

Please sign in to comment.