Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restored testing of non-TrueType default font #7748

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Tests/test_font_leaks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

from PIL import Image, ImageDraw, ImageFont
from PIL import Image, ImageDraw, ImageFont, _util

from .helper import PillowLeakTestCase, skip_unless_feature
from .helper import PillowLeakTestCase, features, skip_unless_feature

original_core = ImageFont.core


class TestTTypeFontLeak(PillowLeakTestCase):
Expand Down Expand Up @@ -31,5 +33,11 @@ class TestDefaultFontLeak(TestTTypeFontLeak):
mem_limit = 1024 # k

def test_leak(self) -> None:
default_font = ImageFont.load_default()
if features.check_module("freetype2"):
ImageFont.core = _util.DeferredError(ImportError)
try:
default_font = ImageFont.load_default()
finally:
ImageFont.core = original_core

self._test_font(default_font)
Loading