From e946c7b14adc7a0aaa9ac883de217a3c0e556a81 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Fri, 7 Mar 2025 02:42:10 +1100 Subject: [PATCH] Test using _seek to skip frames (#8804) Co-authored-by: Andrew Murray --- Tests/test_file_apng.py | 5 ++++- Tests/test_file_fli.py | 3 +++ Tests/test_file_gif.py | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index 9d5154fca..b9a036173 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -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) diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 8adbd30f5..8a95af62d 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -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", diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index d2592da97..dbbffc675 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -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: