test {ImageFont,TransposedFont}.getsize() deprecation

This commit is contained in:
nulano 2022-07-01 11:22:47 +02:00
parent a37c21e136
commit 74e0b954f2
No known key found for this signature in database
GPG Key ID: B650CDF63B705766
2 changed files with 7 additions and 2 deletions

View File

@ -82,6 +82,9 @@ def test_textsize(request, tmp_path):
assert dy == 20 assert dy == 20
assert dx in (0, 10) assert dx in (0, 10)
assert font.getlength(chr(i)) == dx assert font.getlength(chr(i)) == dx
with pytest.warns(DeprecationWarning) as log:
assert font.getsize(chr(i)) == (dx, dy)
assert len(log) == 1
for i in range(len(message)): for i in range(len(message)):
msg = message[: i + 1] msg = message[: i + 1]
assert font.getlength(msg) == len(msg) * 10 assert font.getlength(msg) == len(msg) * 10

View File

@ -317,14 +317,16 @@ class TestImageFont:
draw.font = font draw.font = font
with pytest.warns(DeprecationWarning) as log: with pytest.warns(DeprecationWarning) as log:
box_size_a = draw.textsize(word) box_size_a = draw.textsize(word)
assert len(log) == 1 assert box_size_a == font.getsize(word)
assert len(log) == 2
bbox_a = draw.textbbox((10, 10), word) bbox_a = draw.textbbox((10, 10), word)
# Rotated font # Rotated font
draw.font = transposed_font draw.font = transposed_font
with pytest.warns(DeprecationWarning) as log: with pytest.warns(DeprecationWarning) as log:
box_size_b = draw.textsize(word) box_size_b = draw.textsize(word)
assert len(log) == 1 assert box_size_b == transposed_font.getsize(word)
assert len(log) == 2
bbox_b = draw.textbbox((20, 20), word) bbox_b = draw.textbbox((20, 20), word)
# Check (w,h) of box a is (h,w) of box b # Check (w,h) of box a is (h,w) of box b