Skip to content

Commit 952d6e9

Browse files
authored
Merge pull request #8766 from radarhere/ftex_test
Improved FtexImagePlugin test coverage
2 parents 5d52ede + ae6bb4c commit 952d6e9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Tests/test_file_ftex.py

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

3+
import io
4+
import struct
5+
36
import pytest
47

58
from PIL import FtexImagePlugin, Image
@@ -23,3 +26,15 @@ def test_invalid_file() -> None:
2326

2427
with pytest.raises(SyntaxError):
2528
FtexImagePlugin.FtexImageFile(invalid_file)
29+
30+
31+
def test_invalid_texture() -> None:
32+
with open("Tests/images/ftex_dxt1.ftc", "rb") as fp:
33+
data = fp.read()
34+
35+
# Change texture compression format
36+
data = data[:24] + struct.pack("<i", 2) + data[28:]
37+
38+
with pytest.raises(ValueError, match="Invalid texture compression format: 2"):
39+
with Image.open(io.BytesIO(data)):
40+
pass

0 commit comments

Comments
 (0)