tests cleanup

This commit is contained in:
nulano 2020-09-09 05:35:55 +02:00
parent ee1cc6ad7c
commit d1edf86953
2 changed files with 22 additions and 7 deletions

View File

@ -1039,7 +1039,7 @@ def test_stroke_descender():
draw.text((10, 0), "y", "#f00", font, stroke_width=2, stroke_fill="#0f0")
# Assert
assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_descender.png", 6.78)
assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_descender.png", 6.76)
@skip_unless_feature("freetype2")

View File

@ -35,9 +35,24 @@ class TestImageFont:
# Freetype has different metrics depending on the version.
# (and, other things, but first things first)
METRICS = {
(">=2.3", "<2.4"): {"multiline": 30, "textsize": 12, "getters": (13, 16)},
(">=2.7",): {"multiline": 6.2, "textsize": 2.5, "getters": (12, 16)},
"Default": {"multiline": 0.5, "textsize": 0.5, "getters": (12, 16)},
(">=2.3", "<2.4"): {
"multiline": 30,
"textsize": 12,
"getters": (13, 16),
"mask": (107, 13),
},
(">=2.7",): {
"multiline": 6.2,
"textsize": 2.5,
"getters": (12, 16),
"mask": (108, 13),
},
"Default": {
"multiline": 0.5,
"textsize": 0.5,
"getters": (12, 16),
"mask": (108, 13),
},
}
@classmethod
@ -343,7 +358,7 @@ class TestImageFont:
mask = transposed_font.getmask(text)
# Assert
assert mask.size in ((13, 107), (13, 108))
assert mask.size == self.metrics["mask"][::-1]
def test_unrotated_transposed_font_get_mask(self):
# Arrange
@ -356,7 +371,7 @@ class TestImageFont:
mask = transposed_font.getmask(text)
# Assert
assert mask.size in ((107, 13), (108, 13))
assert mask.size == self.metrics["mask"]
def test_free_type_font_get_name(self):
# Arrange
@ -400,7 +415,7 @@ class TestImageFont:
mask = font.getmask(text)
# Assert
assert mask.size in ((107, 13), (108, 13))
assert mask.size == self.metrics["mask"]
def test_load_path_not_found(self):
# Arrange