Updated type hints
This commit is contained in:
parent
e16a47be90
commit
24ed005fb3
@ -4,13 +4,14 @@ from io import BytesIO
|
||||
|
||||
import pytest
|
||||
|
||||
from PIL import Image
|
||||
from PIL import AniImagePlugin, Image
|
||||
|
||||
from .helper import assert_image_equal_tofile
|
||||
|
||||
|
||||
def test_aero_busy() -> None:
|
||||
with Image.open("Tests/images/ani/aero_busy.ani") as im:
|
||||
assert isinstance(im, AniImagePlugin.AniImageFile)
|
||||
assert im.size == (64, 64)
|
||||
assert im.n_frames == 18
|
||||
|
||||
@ -29,6 +30,7 @@ def test_aero_busy() -> None:
|
||||
|
||||
def test_posy_busy() -> None:
|
||||
with Image.open("Tests/images/ani/posy_busy.ani") as im:
|
||||
assert isinstance(im, AniImagePlugin.AniImageFile)
|
||||
assert im.size == (96, 96)
|
||||
assert im.n_frames == 77
|
||||
|
||||
@ -43,6 +45,7 @@ def test_posy_busy() -> None:
|
||||
|
||||
def test_seq_rate() -> None:
|
||||
with Image.open("Tests/images/ani/stopwtch.ani") as im:
|
||||
assert isinstance(im, AniImagePlugin.AniImageFile)
|
||||
assert im.size == (32, 32)
|
||||
assert im.n_frames == 8
|
||||
|
||||
@ -122,6 +125,7 @@ def test_save() -> None:
|
||||
)
|
||||
|
||||
with Image.open(output, formats=["ANI"]) as im:
|
||||
assert isinstance(im, AniImagePlugin.AniImageFile)
|
||||
assert im.n_frames == 6
|
||||
assert im.info["seq"] == [0, 2, 4, 1, 3, 5, 0, 1, 0, 1]
|
||||
assert im.info["rate"] == [1, 2, 3, 1, 2, 3, 1, 2, 3, 4]
|
||||
|
||||
@ -59,6 +59,7 @@ def test_posy_link() -> None:
|
||||
assert im.getpixel((20, 20)) == (0, 0, 0, 255)
|
||||
assert im.getpixel((40, 40)) == (255, 255, 255, 255)
|
||||
|
||||
assert isinstance(im, CurImagePlugin.CurImageFile)
|
||||
im.size = (32, 32)
|
||||
im.load()
|
||||
assert im.getpixel((0, 0)) == (0, 0, 0, 0)
|
||||
|
||||
@ -283,7 +283,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||
|
||||
|
||||
class AniFile:
|
||||
def __init__(self, fp: BytesIO) -> None:
|
||||
def __init__(self, fp: IO[bytes]) -> None:
|
||||
if not _accept(fp.read(4)):
|
||||
SyntaxError("Not an ANI file")
|
||||
|
||||
@ -394,6 +394,7 @@ class AniImageFile(ImageFile.ImageFile):
|
||||
format_description = "Windows Animated Cursor"
|
||||
|
||||
def _open(self) -> None:
|
||||
assert self.fp is not None
|
||||
self.ani = AniFile(self.fp)
|
||||
self.info["seq"] = self.ani.seq
|
||||
self.info["rate"] = self.ani.rate
|
||||
|
||||
Loading…
Reference in New Issue
Block a user