mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
Test invalid texture compression format
This commit is contained in:
parent
769a14dca5
commit
ae6bb4cac2
|
@ -1,5 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import io
|
||||||
|
import struct
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import FtexImagePlugin, Image
|
from PIL import FtexImagePlugin, Image
|
||||||
|
@ -23,3 +26,15 @@ def test_invalid_file() -> None:
|
||||||
|
|
||||||
with pytest.raises(SyntaxError):
|
with pytest.raises(SyntaxError):
|
||||||
FtexImagePlugin.FtexImageFile(invalid_file)
|
FtexImagePlugin.FtexImageFile(invalid_file)
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_texture() -> None:
|
||||||
|
with open("Tests/images/ftex_dxt1.ftc", "rb") as fp:
|
||||||
|
data = fp.read()
|
||||||
|
|
||||||
|
# Change texture compression format
|
||||||
|
data = data[:24] + struct.pack("<i", 2) + data[28:]
|
||||||
|
|
||||||
|
with pytest.raises(ValueError, match="Invalid texture compression format: 2"):
|
||||||
|
with Image.open(io.BytesIO(data)):
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user