From 9006836c28268a460cbf7a0c6ef3f9c46ed21875 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 22 Feb 2022 08:55:02 +1100 Subject: [PATCH] Test that n_frames and is_animated do not change the image --- Tests/test_file_gif.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 64a551f8a..011d982f0 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -308,6 +308,22 @@ def test_n_frames(): assert im.is_animated == (n_frames != 1) +def test_no_change(): + # Test n_frames does not change the image + with Image.open("Tests/images/dispose_bgnd.gif") as im: + im.seek(1) + expected = im.copy() + assert im.n_frames == 5 + assert_image_equal(im, expected) + + # Test is_animated does not change the image + with Image.open("Tests/images/dispose_bgnd.gif") as im: + im.seek(3) + expected = im.copy() + assert im.is_animated + assert_image_equal(im, expected) + + def test_eoferror(): with Image.open(TEST_GIF) as im: n_frames = im.n_frames