Skip to content

Commit c7ed097

Browse files
authored
Merge pull request #8783 from radarhere/bdf
Improved BdfFontFile test coverage
2 parents 5187b54 + 5ce8929 commit c7ed097

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Tests/test_font_bdf.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import io
4+
35
import pytest
46

57
from PIL import BdfFontFile, FontFile
@@ -8,13 +10,20 @@
810

911

1012
def test_sanity() -> None:
11-
with open(filename, "rb") as test_file:
12-
font = BdfFontFile.BdfFontFile(test_file)
13+
with open(filename, "rb") as fp:
14+
font = BdfFontFile.BdfFontFile(fp)
1315

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

1719

20+
def test_zero_width_chars() -> None:
21+
with open(filename, "rb") as fp:
22+
data = fp.read()
23+
data = data[:2650] + b"\x00\x00" + data[2652:]
24+
BdfFontFile.BdfFontFile(io.BytesIO(data))
25+
26+
1827
def test_invalid_file() -> None:
1928
with open("Tests/images/flower.jpg", "rb") as fp:
2029
with pytest.raises(SyntaxError):

0 commit comments

Comments
 (0)