mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 11:53:32 +03:00
Assert image type
This commit is contained in:
parent
cb3a4b4b57
commit
6ee9d5362c
|
@ -14,6 +14,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import (
|
from PIL import (
|
||||||
AvifImagePlugin,
|
AvifImagePlugin,
|
||||||
|
GifImagePlugin,
|
||||||
Image,
|
Image,
|
||||||
ImageDraw,
|
ImageDraw,
|
||||||
ImageFile,
|
ImageFile,
|
||||||
|
@ -240,6 +241,7 @@ class TestFileAvif:
|
||||||
with Image.open("Tests/images/chi.gif") as im:
|
with Image.open("Tests/images/chi.gif") as im:
|
||||||
im.save(temp_file)
|
im.save(temp_file)
|
||||||
with Image.open(temp_file) as im:
|
with Image.open(temp_file) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 1
|
assert im.n_frames == 1
|
||||||
|
|
||||||
def test_invalid_file(self) -> None:
|
def test_invalid_file(self) -> None:
|
||||||
|
@ -595,10 +597,12 @@ class TestAvifAnimation:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with Image.open(TEST_AVIF_FILE) as im:
|
with Image.open(TEST_AVIF_FILE) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 1
|
assert im.n_frames == 1
|
||||||
assert not im.is_animated
|
assert not im.is_animated
|
||||||
|
|
||||||
with Image.open("Tests/images/avif/star.avifs") as im:
|
with Image.open("Tests/images/avif/star.avifs") as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 5
|
assert im.n_frames == 5
|
||||||
assert im.is_animated
|
assert im.is_animated
|
||||||
|
|
||||||
|
@ -609,11 +613,13 @@ class TestAvifAnimation:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with Image.open("Tests/images/avif/star.gif") as original:
|
with Image.open("Tests/images/avif/star.gif") as original:
|
||||||
|
assert isinstance(original, GifImagePlugin.GifImageFile)
|
||||||
assert original.n_frames > 1
|
assert original.n_frames > 1
|
||||||
|
|
||||||
temp_file = tmp_path / "temp.avif"
|
temp_file = tmp_path / "temp.avif"
|
||||||
original.save(temp_file, save_all=True)
|
original.save(temp_file, save_all=True)
|
||||||
with Image.open(temp_file) as im:
|
with Image.open(temp_file) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == original.n_frames
|
assert im.n_frames == original.n_frames
|
||||||
|
|
||||||
# Compare first frame in P mode to frame from original GIF
|
# Compare first frame in P mode to frame from original GIF
|
||||||
|
@ -633,6 +639,7 @@ class TestAvifAnimation:
|
||||||
|
|
||||||
def check(temp_file: Path) -> None:
|
def check(temp_file: Path) -> None:
|
||||||
with Image.open(temp_file) as im:
|
with Image.open(temp_file) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 4
|
assert im.n_frames == 4
|
||||||
|
|
||||||
# Compare first frame to original
|
# Compare first frame to original
|
||||||
|
@ -705,6 +712,7 @@ class TestAvifAnimation:
|
||||||
)
|
)
|
||||||
|
|
||||||
with Image.open(temp_file) as im:
|
with Image.open(temp_file) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 5
|
assert im.n_frames == 5
|
||||||
assert im.is_animated
|
assert im.is_animated
|
||||||
|
|
||||||
|
@ -734,6 +742,7 @@ class TestAvifAnimation:
|
||||||
)
|
)
|
||||||
|
|
||||||
with Image.open(temp_file) as im:
|
with Image.open(temp_file) as im:
|
||||||
|
assert isinstance(im, AvifImagePlugin.AvifImageFile)
|
||||||
assert im.n_frames == 5
|
assert im.n_frames == 5
|
||||||
assert im.is_animated
|
assert im.is_animated
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user