Skip to content

Commit dce9608

Browse files
committed
Test unknown colour and missing colour key
1 parent 34efaad commit dce9608

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Tests/test_file_xpm.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,23 @@ def test_rgb() -> None:
3333
assert_image_similar(im, hopper(), 16)
3434

3535

36+
def test_cannot_read() -> None:
37+
with open(TEST_FILE, "rb") as fp:
38+
data = fp.read().split(b"#")[0]
39+
with pytest.raises(ValueError, match="cannot read this XPM file"):
40+
with Image.open(BytesIO(data)) as im:
41+
pass
42+
with pytest.raises(ValueError, match="cannot read this XPM file"):
43+
with Image.open(BytesIO(data+b"invalid")) as im:
44+
pass
45+
46+
3647
def test_not_enough_image_data() -> None:
3748
with open(TEST_FILE, "rb") as fp:
3849
data = fp.read().split(b"/* pixels */")[0]
39-
with Image.open(BytesIO(data)) as im:
40-
with pytest.raises(ValueError, match="not enough image data"):
41-
im.load()
50+
with Image.open(BytesIO(data)) as im:
51+
with pytest.raises(ValueError, match="not enough image data"):
52+
im.load()
4253

4354

4455
def test_invalid_file() -> None:

0 commit comments

Comments
 (0)