Skip to content

Commit 3d587ee

Browse files
committed
Only skip test if libimagequant is earlier than 4 on ppc64le
1 parent cac305f commit 3d587ee

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Tests/test_image_quantize.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 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

89
def 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")
2122
def 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

Comments
 (0)