@@ -34,8 +34,35 @@ def require_artresizer_compare(test):
34
34
def wrapper (* args , ** kwargs ):
35
35
if not ArtResizer .shared .can_compare :
36
36
raise unittest .SkipTest ("compare not available" )
37
- else :
38
- return test (* args , ** kwargs )
37
+
38
+ # PHASH computation in ImageMagick changed at some point in an
39
+ # undocumented way. Check at a low level that comparisons of our
40
+ # fixtures give the expected results. Only then, plugin logic tests
41
+ # below are meaningful.
42
+ # cf. https://github.com/ImageMagick/ImageMagick/discussions/5191
43
+ # It would be better to investigate what exactly change in IM and
44
+ # handle that in ArtResizer.IMBackend.{can_compare,compare}.
45
+ # Skipping the tests as below is a quick fix to CI, but users may
46
+ # still see unexpected behaviour.
47
+ abbey_artpath = os .path .join (_common .RSRC , b"abbey.jpg" )
48
+ abbey_similarpath = os .path .join (_common .RSRC , b"abbey-similar.jpg" )
49
+ abbey_differentpath = os .path .join (_common .RSRC , b"abbey-different.jpg" )
50
+ compare_threshold = 20
51
+
52
+ similar_compares_ok = ArtResizer .shared .compare (
53
+ abbey_artpath ,
54
+ abbey_similarpath ,
55
+ compare_threshold ,
56
+ )
57
+ different_compares_ok = ArtResizer .shared .compare (
58
+ abbey_artpath ,
59
+ abbey_differentpath ,
60
+ compare_threshold ,
61
+ )
62
+ if not similar_compares_ok or different_compares_ok :
63
+ raise unittest .SkipTest ("IM version with broken compare" )
64
+
65
+ return test (* args , ** kwargs )
39
66
40
67
wrapper .__name__ = test .__name__
41
68
return wrapper
0 commit comments