mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Added IMT tests
This commit is contained in:
parent
aa8877ac5b
commit
d402fe0b17
BIN
Tests/images/bw_gradient.imt
Normal file
BIN
Tests/images/bw_gradient.imt
Normal file
Binary file not shown.
19
Tests/test_file_imt.py
Normal file
19
Tests/test_file_imt.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import io
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from PIL import Image, ImtImagePlugin
|
||||||
|
|
||||||
|
from .helper import assert_image_equal_tofile
|
||||||
|
|
||||||
|
|
||||||
|
def test_sanity():
|
||||||
|
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"))
|
||||||
|
def test_invalid_file(data):
|
||||||
|
with io.BytesIO(data) as fp:
|
||||||
|
with pytest.raises(SyntaxError):
|
||||||
|
ImtImagePlugin.ImtImageFile(fp)
|
|
@ -74,13 +74,13 @@ class ImtImageFile(ImageFile.ImageFile):
|
||||||
if not m:
|
if not m:
|
||||||
break
|
break
|
||||||
k, v = m.group(1, 2)
|
k, v = m.group(1, 2)
|
||||||
if k == "width":
|
if k == b"width":
|
||||||
xsize = int(v)
|
xsize = int(v)
|
||||||
self._size = xsize, ysize
|
self._size = xsize, ysize
|
||||||
elif k == "height":
|
elif k == b"height":
|
||||||
ysize = int(v)
|
ysize = int(v)
|
||||||
self._size = xsize, ysize
|
self._size = xsize, ysize
|
||||||
elif k == "pixel" and v == "n8":
|
elif k == b"pixel" and v == b"n8":
|
||||||
self.mode = "L"
|
self.mode = "L"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user