diff --git a/Tests/test_file_ftex.py b/Tests/test_file_ftex.py index fdd7b375762..99cf36a6ffe 100644 --- a/Tests/test_file_ftex.py +++ b/Tests/test_file_ftex.py @@ -38,3 +38,13 @@ def test_invalid_texture() -> None: with pytest.raises(ValueError, match="Invalid texture compression format: 2"): with Image.open(io.BytesIO(data)): pass + + +def test_unsupported_texture_format_count() -> None: + with open("Tests/images/ftex_dxt1.ftc", "rb") as fp: + # Change the format count to an unsupported value + data = fp.read(20) + struct.pack(" None: # Only support single-format files. # I don't know of any multi-format file. - assert format_count == 1 + if format_count != 1: + msg = f"Unsupported number of texture formats: {format_count}" + raise ValueError(msg) format, where = struct.unpack("<2i", self.fp.read(8)) self.fp.seek(where)