2022-01-15 02:07:07 +03:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from PIL import FtexImagePlugin, Image
|
2016-01-30 16:22:02 +03:00
|
|
|
|
2021-02-21 14:15:56 +03:00
|
|
|
from .helper import assert_image_equal_tofile, assert_image_similar
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2016-02-05 01:57:13 +03:00
|
|
|
|
2020-02-25 12:57:27 +03:00
|
|
|
def test_load_raw():
|
|
|
|
with Image.open("Tests/images/ftex_uncompressed.ftu") as im:
|
2021-02-21 14:15:56 +03:00
|
|
|
assert_image_equal_tofile(im, "Tests/images/ftex_uncompressed.png")
|
2016-01-30 16:22:02 +03:00
|
|
|
|
2020-02-25 12:57:27 +03:00
|
|
|
|
|
|
|
def test_load_dxt1():
|
|
|
|
with Image.open("Tests/images/ftex_dxt1.ftc") as im:
|
|
|
|
with Image.open("Tests/images/ftex_dxt1.png") as target:
|
|
|
|
assert_image_similar(im, target.convert("RGBA"), 15)
|
2022-01-15 02:07:07 +03:00
|
|
|
|
|
|
|
|
2022-02-27 06:47:07 +03:00
|
|
|
def test_invalid_file():
|
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
|
|
|
|
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
FtexImagePlugin.FtexImageFile(invalid_file)
|
|
|
|
|
|
|
|
|
2022-01-15 02:07:07 +03:00
|
|
|
def test_constants_deprecation():
|
|
|
|
for enum, prefix in {
|
|
|
|
FtexImagePlugin.Format: "FORMAT_",
|
|
|
|
}.items():
|
|
|
|
for name in enum.__members__:
|
|
|
|
with pytest.warns(DeprecationWarning):
|
|
|
|
assert getattr(FtexImagePlugin, prefix + name) == enum[name]
|