Test using _seek to skip frames (#8804)

Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
This commit is contained in:
Andrew Murray 2025-03-07 02:42:10 +11:00 committed by GitHub
parent 5ba72a9b54
commit e946c7b14a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -34,8 +34,11 @@ def test_apng_basic() -> None:
with pytest.raises(EOFError): with pytest.raises(EOFError):
im.seek(2) im.seek(2)
# test rewind support
im.seek(0) im.seek(0)
with pytest.raises(ValueError, match="cannot seek to frame 2"):
im._seek(2)
# test rewind support
assert im.getpixel((0, 0)) == (255, 0, 0, 255) assert im.getpixel((0, 0)) == (255, 0, 0, 255)
assert im.getpixel((64, 32)) == (255, 0, 0, 255) assert im.getpixel((64, 32)) == (255, 0, 0, 255)
im.seek(1) im.seek(1)

View File

@ -160,6 +160,9 @@ def test_seek() -> None:
assert_image_equal_tofile(im, "Tests/images/a_fli.png") assert_image_equal_tofile(im, "Tests/images/a_fli.png")
with pytest.raises(ValueError, match="cannot seek to frame 52"):
im._seek(52)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"test_file", "test_file",

View File

@ -410,6 +410,10 @@ def test_seek() -> None:
except EOFError: except EOFError:
assert frame_count == 5 assert frame_count == 5
img.seek(0)
with pytest.raises(ValueError, match="cannot seek to frame 2"):
img._seek(2)
def test_seek_info() -> None: def test_seek_info() -> None:
with Image.open("Tests/images/iss634.gif") as im: with Image.open("Tests/images/iss634.gif") as im: