2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2022-09-29 01:22:01 +03:00
|
|
|
import io
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from PIL import Image, ImtImagePlugin
|
|
|
|
|
|
|
|
from .helper import assert_image_equal_tofile
|
|
|
|
|
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_sanity() -> None:
|
2022-09-29 01:22:01 +03:00
|
|
|
with Image.open("Tests/images/bw_gradient.imt") as im:
|
|
|
|
assert_image_equal_tofile(im, "Tests/images/bw_gradient.png")
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("data", (b"\n", b"\n-", b"width 1\n"))
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_invalid_file(data: bytes) -> None:
|
2022-09-29 01:22:01 +03:00
|
|
|
with io.BytesIO(data) as fp:
|
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
ImtImagePlugin.ImtImageFile(fp)
|