Skip to content

Commit

Permalink
Merge pull request #8783 from radarhere/bdf
Browse files Browse the repository at this point in the history
Improved BdfFontFile test coverage
  • Loading branch information
radarhere authored Mar 3, 2025
2 parents 5187b54 + 5ce8929 commit c7ed097
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Tests/test_font_bdf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import io

import pytest

from PIL import BdfFontFile, FontFile
Expand All @@ -8,13 +10,20 @@


def test_sanity() -> None:
with open(filename, "rb") as test_file:
font = BdfFontFile.BdfFontFile(test_file)
with open(filename, "rb") as fp:
font = BdfFontFile.BdfFontFile(fp)

assert isinstance(font, FontFile.FontFile)
assert len([_f for _f in font.glyph if _f]) == 190


def test_zero_width_chars() -> None:
with open(filename, "rb") as fp:
data = fp.read()
data = data[:2650] + b"\x00\x00" + data[2652:]
BdfFontFile.BdfFontFile(io.BytesIO(data))


def test_invalid_file() -> None:
with open("Tests/images/flower.jpg", "rb") as fp:
with pytest.raises(SyntaxError):
Expand Down

0 comments on commit c7ed097

Please sign in to comment.