tests: comparators.image: fixes test_ico_image for identify >= 6.9.8

A change was made to ImageMagick in April which caused "File size"
from identify -verbose to display base 2 numbers, instead of the
previous base 10. This caused test_diff_meta to fail on newer
versions of ImageMagick.

ImageMagick commits #b6b00dad #ed597120: "SI units for filesize"
Signed-off-by: default avatarJuliana Oliveira Rodrigues <juliana.orod@gmail.com>
parent 145d3647
......@@ -23,7 +23,8 @@ from diffoscope.comparators.image import ICOImageFile
from diffoscope.config import Config
from ..utils.data import load_fixture, get_data
from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
from ..utils.tools import (skip_unless_tools_exist,
skip_unless_tool_is_at_least, skip_unless_tool_is_between)
from .test_jpeg_image import identify_version
......@@ -53,11 +54,17 @@ def differences_meta(image1_meta, image2_meta):
return image1_meta.compare(image2_meta).details
@skip_unless_tools_exist('img2txt', 'identify')
@skip_unless_tool_is_at_least('identify', identify_version, '6.9.6')
@skip_unless_tool_is_between('identify', identify_version, '6.9.6', '6.9.8-3')
def test_diff_meta(differences_meta):
expected_diff = get_data('ico_image_meta_expected_diff')
assert differences_meta[-1].unified_diff == expected_diff
@skip_unless_tools_exist('img2txt', 'identify')
@skip_unless_tool_is_at_least('identify', identify_version, '6.9.8-4')
def test_diff_meta(differences_meta):
expected_diff = get_data('ico_image_meta_expected_diff_v2')
assert differences_meta[-1].unified_diff == expected_diff
@skip_unless_tools_exist('img2txt', 'compose', 'convert', 'identify')
def test_has_visuals(monkeypatch, image1, image2):
monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
......
@@ -1,17 +1,17 @@
Image format: ICO
-File size: 6926B
+File size: 3270B
Height: 100
Width: 100
Orientation: Undefined
Compression type: Undefined
Compression quality: 0
Colorspace: sRGB
Channels: srgba
-Depth: 4
+Depth: 1
Interlace mode: None
Rendering intent: Perceptual
X resolution: 0
Y resolution: 0
Resolution units: Undefined
Transparency channel enabled: True
Gamma: 0.454545
......@@ -46,6 +46,28 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
reason="requires {} >= {} ({} detected)".format(tool, min_ver, actual_ver)
)
def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=LooseVersion):
if tools_missing(tool):
return pytest.mark.skipif(True, reason="requires {}".format(tool))
if callable(actual_ver):
actual_ver = actual_ver()
return pytest.mark.skipif(
vcls(str(actual_ver)) > vcls(str(max_ver)),
reason="requires {} <= {} ({} detected)".format(tool, max_ver, actual_ver)
)
def skip_unless_tool_is_between(tool, actual_ver, min_ver, max_ver, vcls=LooseVersion):
if tools_missing(tool):
return pytest.mark.skipif(True, reason="requires {}".format(tool))
if callable(actual_ver):
actual_ver = actual_ver()
return pytest.mark.skipif(
( vcls(str(actual_ver)) < vcls(str(min_ver)))
or (vcls(str(actual_ver)) > vcls(str(max_ver))),
reason="requires {} >= {} >= {} ({} detected)".format(min_ver, tool,
max_ver, actual_ver)
)
def skip_if_binutils_does_not_support_x86():
if tools_missing('objdump'):
return skip_unless_tools_exist('objdump')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment