mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
test {ImageFont,TransposedFont}.getsize() deprecation
This commit is contained in:
parent
a37c21e136
commit
74e0b954f2
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user