2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
import pytest
|
2020-08-07 13:28:33 +03:00
|
|
|
|
2017-02-28 09:27:53 +03:00
|
|
|
from PIL import Image, PixarImagePlugin
|
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
from .helper import assert_image_similar, hopper
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2017-02-28 09:27:53 +03:00
|
|
|
TEST_FILE = "Tests/images/hopper.pxr"
|
|
|
|
|
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_sanity() -> None:
|
2020-02-12 19:29:19 +03:00
|
|
|
with Image.open(TEST_FILE) as im:
|
|
|
|
im.load()
|
|
|
|
assert im.mode == "RGB"
|
|
|
|
assert im.size == (128, 128)
|
|
|
|
assert im.format == "PIXAR"
|
|
|
|
assert im.get_format_mimetype() is None
|
2017-02-28 09:27:53 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
im2 = hopper()
|
|
|
|
assert_image_similar(im, im2, 4.8)
|
2017-02-28 09:27:53 +03:00
|
|
|
|
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_invalid_file() -> None:
|
2020-02-12 19:29:19 +03:00
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
|
|
|
|
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
PixarImagePlugin.PixarImageFile(invalid_file)
|