Skip to content

Commit 723e764

Browse files
committed
Improved coverage
1 parent 612e3c2 commit 723e764

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Tests/test_fontfile.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
from __future__ import annotations
22

3+
from io import BytesIO
34
from pathlib import Path
45

56
import pytest
67

78
from PIL import FontFile, Image
89

910

11+
def test_puti16() -> None:
12+
fp = BytesIO()
13+
FontFile.puti16(fp, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
14+
assert fp.getvalue() == (
15+
b"\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04"
16+
b"\x00\x05\x00\x06\x00\x07\x00\x08\x00\t"
17+
)
18+
19+
1020
def test_compile() -> None:
1121
font = FontFile.FontFile()
1222
font.glyph[0] = ((0, 0), (0, 0, 0, 0), (0, 0, 0, 1), Image.new("L", (0, 0)))
@@ -24,5 +34,11 @@ def test_save(tmp_path: Path) -> None:
2434
tempname = str(tmp_path / "temp.pil")
2535

2636
font = FontFile.FontFile()
27-
with pytest.raises(ValueError):
37+
with pytest.raises(ValueError, match="No bitmap created"):
2838
font.save(tempname)
39+
40+
41+
def test_to_imagefont() -> None:
42+
font = FontFile.FontFile()
43+
with pytest.raises(ValueError, match="No bitmap created"):
44+
font.to_imagefont()

0 commit comments

Comments
 (0)