mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-13 09:15:46 +03:00
Test ValueError
This commit is contained in:
parent
d7d48df9af
commit
ff4f5d4cb6
|
@ -1,5 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import io
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import BdfFontFile, FontFile
|
from PIL import BdfFontFile, FontFile
|
||||||
|
@ -8,13 +10,20 @@ filename = "Tests/images/courB08.bdf"
|
||||||
|
|
||||||
|
|
||||||
def test_sanity() -> None:
|
def test_sanity() -> None:
|
||||||
with open(filename, "rb") as test_file:
|
with open(filename, "rb") as fp:
|
||||||
font = BdfFontFile.BdfFontFile(test_file)
|
font = BdfFontFile.BdfFontFile(fp)
|
||||||
|
|
||||||
assert isinstance(font, FontFile.FontFile)
|
assert isinstance(font, FontFile.FontFile)
|
||||||
assert len([_f for _f in font.glyph if _f]) == 190
|
assert len([_f for _f in font.glyph if _f]) == 190
|
||||||
|
|
||||||
|
|
||||||
|
def test_valueerror() -> 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:
|
def test_invalid_file() -> None:
|
||||||
with open("Tests/images/flower.jpg", "rb") as fp:
|
with open("Tests/images/flower.jpg", "rb") as fp:
|
||||||
with pytest.raises(SyntaxError):
|
with pytest.raises(SyntaxError):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user