From 74e0b954f2010b0e2e19166b1defad2f4ed6307c Mon Sep 17 00:00:00 2001 From: nulano Date: Fri, 1 Jul 2022 11:22:47 +0200 Subject: [PATCH] test {ImageFont,TransposedFont}.getsize() deprecation --- Tests/test_font_pcf.py | 3 +++ Tests/test_imagefont.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index 815ef1d9254..c217378fb74 100644 --- a/Tests/test_font_pcf.py +++ b/Tests/test_font_pcf.py @@ -82,6 +82,9 @@ def test_textsize(request, tmp_path): assert dy == 20 assert dx in (0, 10) 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)): msg = message[: i + 1] assert font.getlength(msg) == len(msg) * 10 diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 606b9ba0ed4..16da87d469a 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -317,14 +317,16 @@ def test_rotated_transposed_font(self): draw.font = font with pytest.warns(DeprecationWarning) as log: 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) # Rotated font draw.font = transposed_font with pytest.warns(DeprecationWarning) as log: 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) # Check (w,h) of box a is (h,w) of box b