Skip to content

Conversation

@radarhere
Copy link
Member

#6035 added a test covering the situation when RAQM is requested but unavailable.

Pillow/Tests/test_imagefont.py

Lines 1027 to 1037 in 9e6537d

def test_raqm_missing_warning(monkeypatch):
monkeypatch.setattr(ImageFont.core, "HAVE_RAQM", False)
with pytest.warns(UserWarning) as record:
font = ImageFont.truetype(
FONT_PATH, FONT_SIZE, layout_engine=ImageFont.Layout.RAQM
)
assert font.layout_engine == ImageFont.Layout.BASIC
assert str(record[-1].message) == (
"Raqm layout was requested, but Raqm is not available. "
"Falling back to basic layout."
)

Turns out, we already had a test for this.

def test_unavailable_layout_engine(self):
have_raqm = ImageFont.core.HAVE_RAQM
ImageFont.core.HAVE_RAQM = False
try:
ttf = ImageFont.truetype(
FONT_PATH, FONT_SIZE, layout_engine=ImageFont.Layout.RAQM
)
finally:
ImageFont.core.HAVE_RAQM = have_raqm
assert ttf.layout_engine == ImageFont.Layout.BASIC

This PR removes the original. The new one appears better as it makes use of monkeypatching.

@hugovk hugovk merged commit bd96420 into python-pillow:main Feb 22, 2022
@radarhere radarhere deleted the duplicate branch February 22, 2022 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants