mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-13 01:05:48 +03:00
31 lines
727 B
Python
31 lines
727 B
Python
from __future__ import annotations
|
|
|
|
import io
|
|
|
|
import pytest
|
|
|
|
from PIL import BdfFontFile, FontFile
|
|
|
|
filename = "Tests/images/courB08.bdf"
|
|
|
|
|
|
def test_sanity() -> None:
|
|
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):
|
|
BdfFontFile.BdfFontFile(fp)
|