tests: skip tests that require ArtResizer.compare if it is broken

This is just a quick workaround to allow CI to pass. This didn't show up
in CI before because we didn't install ImageMagick.
This commit is contained in:
wisp3rwind 2025-04-14 12:04:26 +02:00
parent ff22da0691
commit abbabcf92e

View file

@ -34,7 +34,34 @@ def require_artresizer_compare(test):
def wrapper(*args, **kwargs):
if not ArtResizer.shared.can_compare:
raise unittest.SkipTest("compare not available")
else:
# PHASH computation in ImageMagick changed at some point in an
# undocumented way. Check at a low level that comparisons of our
# fixtures give the expected results. Only then, plugin logic tests
# below are meaningful.
# cf. https://github.com/ImageMagick/ImageMagick/discussions/5191
# It would be better to investigate what exactly change in IM and
# handle that in ArtResizer.IMBackend.{can_compare,compare}.
# Skipping the tests as below is a quick fix to CI, but users may
# still see unexpected behaviour.
abbey_artpath = os.path.join(_common.RSRC, b"abbey.jpg")
abbey_similarpath = os.path.join(_common.RSRC, b"abbey-similar.jpg")
abbey_differentpath = os.path.join(_common.RSRC, b"abbey-different.jpg")
compare_threshold = 20
similar_compares_ok = ArtResizer.shared.compare(
abbey_artpath,
abbey_similarpath,
compare_threshold,
)
different_compares_ok = ArtResizer.shared.compare(
abbey_artpath,
abbey_differentpath,
compare_threshold,
)
if not similar_compares_ok or different_compares_ok:
raise unittest.SkipTest("IM version with broken compare")
return test(*args, **kwargs)
wrapper.__name__ = test.__name__