[diffoscope] 01/01: tests: comparators.image: fixes test_ico_image for identify >= 6.9.8

Juliana Oliveira R jwnx-guest at moszumanska.debian.org
Thu Jul 27 22:06:23 CEST 2017


This is an automated email from the git hooks/post-receive script.

jwnx-guest pushed a commit to branch WIP/jwnx/fixes_test_ico_image_for_imagemagick_newer_than_6.9.8
in repository diffoscope.

commit 2199b9494f1137c13b177264e289080deccb06cb
Author: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
Date:   Wed Jul 26 23:53:53 2017 -0300

    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: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
---
 tests/comparators/test_ico_image.py        | 11 +++++++++--
 tests/data/ico_image_meta_expected_diff_v2 | 20 ++++++++++++++++++++
 tests/utils/tools.py                       | 22 ++++++++++++++++++++++
 3 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/tests/comparators/test_ico_image.py b/tests/comparators/test_ico_image.py
index b026d3e..113e491 100644
--- a/tests/comparators/test_ico_image.py
+++ b/tests/comparators/test_ico_image.py
@@ -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')
- at skip_unless_tool_is_at_least('identify', identify_version, '6.9.6')
+ at 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
 
+ at skip_unless_tools_exist('img2txt', 'identify')
+ at skip_unless_tool_is_between('identify', identify_version, '6.9.8-4', '7')
+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)
diff --git a/tests/data/ico_image_meta_expected_diff_v2 b/tests/data/ico_image_meta_expected_diff_v2
new file mode 100644
index 0000000..37246e6
--- /dev/null
+++ b/tests/data/ico_image_meta_expected_diff_v2
@@ -0,0 +1,20 @@
+@@ -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
diff --git a/tests/utils/tools.py b/tests/utils/tools.py
index 20b3af9..c58c6a3 100644
--- a/tests/utils/tools.py
+++ b/tests/utils/tools.py
@@ -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')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list