11import pytest
2+ from packaging .version import parse as parse_version
23
3- from PIL import Image
4+ from PIL import Image , features
45
5- from .helper import assert_image_similar , hopper , is_ppc64le
6+ from .helper import assert_image_similar , hopper , is_ppc64le , skip_unless_feature
67
78
89def test_sanity ():
@@ -17,16 +18,14 @@ def test_sanity():
1718 assert_image_similar (converted .convert ("RGB" ), image , 60 )
1819
1920
20- @pytest . mark . xfail ( is_ppc64le (), reason = "failing on ppc64le on GHA " )
21+ @skip_unless_feature ( "libimagequant " )
2122def test_libimagequant_quantize ():
2223 image = hopper ()
23- try :
24- converted = image .quantize (100 , Image .LIBIMAGEQUANT )
25- except ValueError as ex : # pragma: no cover
26- if "dependency" in str (ex ).lower ():
27- pytest .skip ("libimagequant support not available" )
28- else :
29- raise
24+ if is_ppc64le ():
25+ libimagequant = parse_version (features .version_feature ("libimagequant" ))
26+ if libimagequant < parse_version ("4" ):
27+ pytest .skip ("Fails with libimagequant earlier than 4.0.0" )
28+ converted = image .quantize (100 , Image .LIBIMAGEQUANT )
3029 assert converted .mode == "P"
3130 assert_image_similar (converted .convert ("RGB" ), image , 15 )
3231 assert len (converted .getcolors ()) == 100
0 commit comments