Skip to content

Commit

Permalink
Test using _seek to skip frames (python-pillow#8804)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Murray <[email protected]>
  • Loading branch information
radarhere and radarhere authored Mar 6, 2025
1 parent 5ba72a9 commit e946c7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tests/test_file_apng.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ def test_apng_basic() -> None:
with pytest.raises(EOFError):
im.seek(2)

# test rewind support
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((64, 32)) == (255, 0, 0, 255)
im.seek(1)
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_file_fli.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def test_seek() -> None:

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(
"test_file",
Expand Down
4 changes: 4 additions & 0 deletions Tests/test_file_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ def test_seek() -> None:
except EOFError:
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:
with Image.open("Tests/images/iss634.gif") as im:
Expand Down

0 comments on commit e946c7b

Please sign in to comment.