[Git][reproducible-builds/diffoscope][master] Move more test modules to use assert_diff.

Chris Lamb gitlab at salsa.debian.org
Wed Aug 12 09:06:41 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
a764a09b by Chris Lamb at 2020-08-12T10:06:19+01:00
Move more test modules to use assert_diff.

Gbp-Dch: ignore

- - - - -


8 changed files:

- tests/comparators/test_elf.py
- tests/comparators/test_ffprobe.py
- tests/comparators/test_fontconfig.py
- tests/comparators/test_fonts.py
- tests/comparators/test_gettext.py
- tests/comparators/test_gif.py
- tests/comparators/test_git.py
- tests/comparators/test_gnumeric.py


Changes:

=====================================
tests/comparators/test_elf.py
=====================================
@@ -31,7 +31,7 @@ from diffoscope.comparators.directory import FilesystemDirectory
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from ..utils.data import data, load_fixture, get_data
+from ..utils.data import data, load_fixture, assert_diff
 from ..utils.tools import (
     skip_unless_tools_exist,
     skip_if_binutils_does_not_support_x86,
@@ -91,8 +91,7 @@ def test_obj_compare_non_existing(monkeypatch, obj1):
 @skip_if_binutils_does_not_support_x86()
 def test_diff(obj_differences):
     assert len(obj_differences) == 1
-    expected_diff = get_data("elf_obj_expected_diff")
-    assert obj_differences[0].unified_diff == expected_diff
+    assert_diff(obj_differences[0], "elf_obj_expected_diff")
 
 
 TEST_LIB1_PATH = data("test1.a")
@@ -129,11 +128,9 @@ def lib_differences(lib1, lib2):
 def test_lib_differences(lib_differences):
     assert len(lib_differences) == 2
     assert lib_differences[0].source1 == "file list"
-    expected_metadata_diff = get_data("elf_lib_metadata_expected_diff")
-    assert lib_differences[0].unified_diff == expected_metadata_diff
+    assert_diff(lib_differences[0], "elf_lib_metadata_expected_diff")
     assert "objdump" in lib_differences[1].details[0].source1
-    expected_objdump_diff = get_data("elf_lib_objdump_expected_diff")
-    assert lib_differences[1].details[0].unified_diff == expected_objdump_diff
+    assert_diff(lib_differences[1].details[0], "elf_lib_objdump_expected_diff")
 
 
 @skip_unless_tools_exist("readelf", "objdump")
@@ -184,10 +181,10 @@ def test_libmix_differences(libmix_differences):
 
     # Content
     assert "return42_or_3" in file_list.unified_diff
-    assert mach_o.unified_diff == get_data("elfmix_mach_o_expected_diff")
-    assert x86_o.unified_diff == get_data("elfmix_disassembly_expected_diff")
-    assert src_c.unified_diff == get_data("elfmix_src_c_expected_diff")
-    assert x_obj.unified_diff == get_data("elfmix_x_obj_expected_diff")
+    assert_diff(mach_o, "elfmix_mach_o_expected_diff")
+    assert_diff(x86_o, "elfmix_disassembly_expected_diff")
+    assert_diff(src_c, "elfmix_src_c_expected_diff")
+    assert_diff(x_obj, "elfmix_x_obj_expected_diff")
 
 
 TEST_DBGSYM_DEB1_PATH = data("dbgsym/add/test-dbgsym_1_amd64.deb")
@@ -242,8 +239,7 @@ def test_differences_with_dbgsym(dbgsym_differences):
 def test_original_gnu_debuglink(dbgsym_differences):
     bin_details = dbgsym_differences.details[2].details[0].details[0]
     assert ".gnu_debuglink" in bin_details.details[3].source1
-    expected_gnu_debuglink = get_data("gnu_debuglink_expected_diff")
-    assert bin_details.details[3].unified_diff == expected_gnu_debuglink
+    assert_diff(bin_details.details[3], "gnu_debuglink_expected_diff")
 
 
 def test_ignore_readelf_errors1_identify(ignore_readelf_errors1):
@@ -265,5 +261,7 @@ def ignore_readelf_errors_differences(
 @skip_if_tool_version_is("readelf", readelf_version, "2.29")
 @skip_if_binutils_does_not_support_x86()
 def test_ignore_readelf_errors(ignore_readelf_errors_differences):
-    expected_diff = get_data("ignore_readelf_errors_expected_diff")
-    assert ignore_readelf_errors_differences[0].unified_diff == expected_diff
+    assert_diff(
+        ignore_readelf_errors_differences[0],
+        "ignore_readelf_errors_expected_diff",
+    )


=====================================
tests/comparators/test_ffprobe.py
=====================================
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.ffprobe import FfprobeFile
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 from ..utils.nonexisting import assert_non_existing
 
@@ -45,8 +45,7 @@ def differences(mp3_1, mp3_2):
 
 @skip_unless_tools_exist("ffprobe")
 def test_diff(differences):
-    expected_diff = get_data("mp3_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "mp3_expected_diff")
 
 
 @skip_unless_tools_exist("ffprobe")


=====================================
tests/comparators/test_fontconfig.py
=====================================
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.fontconfig import FontconfigCacheFile
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 
 cache1 = load_fixture("test1-le64.cache-4")
 cache2 = load_fixture("test2-le64.cache-4")
@@ -42,5 +42,4 @@ def differences(cache1, cache2):
 
 
 def test_diff(differences):
-    expected_diff = get_data("fontconfig_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "fontconfig_expected_diff")


=====================================
tests/comparators/test_fonts.py
=====================================
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.fonts import TtfFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 
 
@@ -48,8 +48,7 @@ def differences(ttf1, ttf2):
 
 @skip_unless_tools_exist("showttf")
 def test_diff(differences):
-    expected_diff = get_data("ttf_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "ttf_expected_diff")
 
 
 @skip_unless_tools_exist("showttf")


=====================================
tests/comparators/test_gettext.py
=====================================
@@ -25,7 +25,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.gettext import MoFile
 
-from ..utils.data import data, load_fixture, get_data
+from ..utils.data import data, load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 
 
@@ -49,8 +49,7 @@ def differences(mo1, mo2):
 
 @skip_unless_tools_exist("msgunfmt")
 def test_diff(differences):
-    expected_diff = get_data("mo_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "mo_expected_diff")
 
 
 mo_no_charset = load_fixture("test_no_charset.mo")


=====================================
tests/comparators/test_gif.py
=====================================
@@ -22,7 +22,7 @@ import pytest
 from diffoscope.comparators.gif import GifFile
 from diffoscope.config import Config
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 from ..utils.nonexisting import assert_non_existing
 
@@ -48,8 +48,7 @@ def differences(gif1, gif2):
 
 @skip_unless_tools_exist("gifbuild")
 def test_diff(differences):
-    expected_diff = get_data("gif_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "gif_expected_diff")
 
 
 @skip_unless_tools_exist("gifbuild")


=====================================
tests/comparators/test_git.py
=====================================
@@ -22,7 +22,7 @@ import pytest
 from diffoscope.tools import get_current_os
 from diffoscope.comparators.git import GitIndexFile
 
-from ..utils.data import get_data, load_fixture
+from ..utils.data import assert_diff, load_fixture
 
 
 git1 = load_fixture("test1.git-index")
@@ -44,7 +44,7 @@ def differences(git1, git2):
 
 def test_diff(differences):
     if get_current_os() == "FreeBSD":
-        expected_diff = get_data("git_expected_diff_freebsd")
+        expected_diff = "git_expected_diff_freebsd"
     else:
-        expected_diff = get_data("git_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+        expected_diff = "git_expected_diff"
+    assert_diff(differences[0], expected_diff)


=====================================
tests/comparators/test_gnumeric.py
=====================================
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.gnumeric import GnumericFile
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 from ..utils.nonexisting import assert_non_existing
 
@@ -45,8 +45,7 @@ def differences(gnumeric1, gnumeric2):
 
 @skip_unless_tools_exist("ssconvert")
 def test_diff(differences):
-    expected_diff = get_data("gnumeric_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "gnumeric_expected_diff")
 
 
 @skip_unless_tools_exist("ssconvert")



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/a764a09b75d8d2b0409cdd2a88428a7fd3a2a16f

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/a764a09b75d8d2b0409cdd2a88428a7fd3a2a16f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200812/26aa90de/attachment.htm>


More information about the rb-commits mailing list