44from pathlib import Path
55
66import pytest
7- from packaging .version import parse as parse_version
87
9- from PIL import GifImagePlugin , Image , WebPImagePlugin , features
8+ from PIL import GifImagePlugin , Image , WebPImagePlugin
109
1110from .helper import (
1211 assert_image_equal ,
1312 assert_image_similar ,
13+ has_feature_version ,
1414 is_big_endian ,
1515 skip_unless_feature ,
1616)
@@ -53,11 +53,8 @@ def test_write_animation_L(tmp_path: Path) -> None:
5353 im .load ()
5454 assert_image_similar (im , orig .convert ("RGBA" ), 32.9 )
5555
56- if is_big_endian ():
57- version = features .version_module ("webp" )
58- assert version is not None
59- if parse_version (version ) < parse_version ("1.2.2" ):
60- pytest .skip ("Fails with libwebp earlier than 1.2.2" )
56+ if is_big_endian () and not has_feature_version ("webp" , "1.2.2" ):
57+ pytest .skip ("Fails with libwebp earlier than 1.2.2" )
6158 orig .seek (orig .n_frames - 1 )
6259 im .seek (im .n_frames - 1 )
6360 orig .load ()
@@ -81,11 +78,8 @@ def check(temp_file: Path) -> None:
8178 assert_image_equal (im , frame1 .convert ("RGBA" ))
8279
8380 # Compare second frame to original
84- if is_big_endian ():
85- version = features .version_module ("webp" )
86- assert version is not None
87- if parse_version (version ) < parse_version ("1.2.2" ):
88- pytest .skip ("Fails with libwebp earlier than 1.2.2" )
81+ if is_big_endian () and not has_feature_version ("webp" , "1.2.2" ):
82+ pytest .skip ("Fails with libwebp earlier than 1.2.2" )
8983 im .seek (1 )
9084 im .load ()
9185 assert_image_equal (im , frame2 .convert ("RGBA" ))
0 commit comments