Loading tests/comparators/test_debian.py +12 −12 Original line number Diff line number Diff line Loading @@ -27,16 +27,16 @@ from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.utils.specialize import specialize from utils.data import data, get_data from utils.tools import skip_unless_module_exists from utils.nonexisting import assert_non_existing try: from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \ DotBuildinfoFile miss_debian_module = False except ImportError: from diffoscope.comparators.debian_fallback import DotChangesFile, DotDscFile, \ DotBuildinfoFile miss_debian_module = True TEST_DOT_CHANGES_FILE1_PATH = data('test1.changes') TEST_DOT_CHANGES_FILE2_PATH = data('test2.changes') Loading Loading @@ -86,7 +86,7 @@ def dot_changes4(tmpdir): def test_dot_changes_identification(dot_changes1): assert isinstance(dot_changes1, DotChangesFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_invalid(tmpdir): tmpdir.mkdir('a') dot_changes_path = str(tmpdir.join('a/test_1.changes')) Loading Loading @@ -120,18 +120,18 @@ def dot_changes_differences_different_contents_and_identical_files(dot_changes2, difference = dot_changes4.compare(dot_changes2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_no_differences_exclude_buildinfo(dot_changes1, dot_changes3): difference = dot_changes1.compare(dot_changes3) assert difference is None @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_identical_contents_and_different_files(dot_changes_differences_identical_contents_and_different_files): assert dot_changes_differences_identical_contents_and_different_files[0] expected_diff = get_data('dot_changes_identical_contents_and_different_files_expected_diff') assert dot_changes_differences_identical_contents_and_different_files[0].unified_diff == expected_diff @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_different_contents_and_identical_files(dot_changes_differences_different_contents_and_identical_files): assert dot_changes_differences_different_contents_and_identical_files[0] assert dot_changes_differences_different_contents_and_identical_files[1] Loading Loading @@ -165,7 +165,7 @@ def dot_dsc2(tmpdir): def test_dot_dsc_identification(dot_dsc1): assert isinstance(dot_dsc1, DotDscFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_invalid(tmpdir, dot_dsc2): tmpdir.mkdir('a') dot_dsc_path = str(tmpdir.join('a/test_1.dsc')) Loading @@ -183,11 +183,11 @@ def dot_dsc_differences(dot_dsc1, dot_dsc2): difference = dot_dsc1.compare(dot_dsc2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_internal_diff(dot_dsc_differences): assert dot_dsc_differences[1].source1 == 'test_1.tar.gz' @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_compare_non_existing(monkeypatch, dot_dsc1): monkeypatch.setattr(Config(), 'new_file', True) difference = dot_dsc1.compare(MissingFile('/nonexisting', dot_dsc1)) Loading Loading @@ -216,7 +216,7 @@ def dot_buildinfo2(tmpdir): def test_dot_buildinfo_identification(dot_buildinfo1): assert isinstance(dot_buildinfo1, DotBuildinfoFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_invalid(tmpdir): tmpdir.mkdir('a') dot_buildinfo_path = str(tmpdir.join('a/test_1.buildinfo')) Loading @@ -234,11 +234,11 @@ def dot_buildinfo_differences(dot_buildinfo1, dot_buildinfo2): difference = dot_buildinfo1.compare(dot_buildinfo2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_internal_diff(dot_buildinfo_differences): assert dot_buildinfo_differences[1].source1 == 'test_1_all.deb' @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_compare_non_existing(monkeypatch, dot_buildinfo1): assert_non_existing(monkeypatch, dot_buildinfo1) Loading tests/comparators/test_elf.py +3 −10 Original line number Diff line number Diff line Loading @@ -29,14 +29,7 @@ from diffoscope.comparators.utils.specialize import specialize from utils.data import data, load_fixture, get_data from utils.tools import skip_unless_tools_exist, \ skip_if_binutils_does_not_support_x86 try: import diffoscope.comparators.debian # noqa miss_debian_module = False except ImportError: miss_debian_module = True skip_if_binutils_does_not_support_x86, skip_unless_module_exists obj1 = load_fixture('test1.o') obj2 = load_fixture('test2.o') Loading Loading @@ -127,7 +120,7 @@ def dbgsym_differences(dbgsym_dir1, dbgsym_dir2): @skip_unless_tools_exist('readelf', 'objdump', 'objcopy') @skip_if_binutils_does_not_support_x86() @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_differences_with_dbgsym(dbgsym_differences): assert dbgsym_differences.details[2].source1 == 'data.tar.xz' bin_details = dbgsym_differences.details[2].details[0].details[0] Loading @@ -137,7 +130,7 @@ def test_differences_with_dbgsym(dbgsym_differences): @skip_unless_tools_exist('readelf', 'objdump', 'objcopy') @skip_if_binutils_does_not_support_x86() @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_original_gnu_debuglink(dbgsym_differences): bin_details = dbgsym_differences.details[2].details[0].details[0] assert '.gnu_debuglink' in bin_details.details[2].source1 Loading tests/comparators/test_fsimage.py +7 −12 Original line number Diff line number Diff line Loading @@ -24,20 +24,15 @@ from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.fsimage import FsImageFile from utils.data import load_fixture, get_data from utils.tools import skip_unless_tools_exist try: import guestfs miss_guestfs = False except ImportError: miss_guestfs = True from utils.tools import skip_unless_tools_exist, skip_unless_module_exists img1 = load_fixture('test1.ext4') img2 = load_fixture('test2.ext4') def guestfs_working(): if miss_guestfs: try: import guestfs except ImportError: return False g = guestfs.GuestFS (python_return_dict=True) g.add_drive_opts("/dev/null", format="raw", readonly=1) Loading @@ -52,7 +47,7 @@ def test_identification(img1): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_no_differences(img1): difference = img1.compare(img1) assert difference is None Loading @@ -63,7 +58,7 @@ def differences(img1, img2): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_differences(differences): assert differences[0].source1 == 'test1.ext4.tar' tarinfo = differences[0].details[0] Loading @@ -81,7 +76,7 @@ def test_differences(differences): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_compare_non_existing(monkeypatch, img1): monkeypatch.setattr(Config(), 'new_file', True) difference = img1.compare(MissingFile('/nonexisting', img1)) Loading tests/comparators/test_rpm.py +6 −8 Original line number Diff line number Diff line Loading @@ -24,16 +24,14 @@ from diffoscope.comparators.binary import FilesystemFile from diffoscope.comparators.utils.specialize import specialize from utils.data import load_fixture, data, get_data from utils.tools import skip_unless_tools_exist from utils.tools import skip_unless_tools_exist, skip_unless_module_exists from utils.nonexisting import assert_non_existing try: from diffoscope.comparators.rpm import RpmFile miss_rpm_module = False except ImportError: from diffoscope.comparators.rpm_fallback import RpmFile miss_rpm_module = True rpm1 = load_fixture('test1.rpm') rpm2 = load_fixture('test2.rpm') Loading @@ -41,7 +39,7 @@ rpm2 = load_fixture('test2.rpm') def test_identification(rpm1): assert isinstance(rpm1, RpmFile) @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') def test_no_differences(rpm1): difference = rpm1.compare(rpm1) assert difference is None Loading @@ -50,14 +48,14 @@ def test_no_differences(rpm1): def differences(rpm1, rpm2): return rpm1.compare(rpm2).details @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_header(differences): assert differences[0].source1 == 'header' expected_diff = get_data('rpm_header_expected_diff') assert differences[0].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_listing(differences): assert differences[1].source1 == 'content' Loading @@ -65,7 +63,7 @@ def test_listing(differences): expected_diff = get_data('rpm_listing_expected_diff') assert differences[1].details[0].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_content(differences): assert differences[1].source1 == 'content' Loading @@ -73,7 +71,7 @@ def test_content(differences): expected_diff = get_data('text_ascii_expected_diff') assert differences[1].details[1].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_compare_non_existing(monkeypatch, rpm1): assert_non_existing(monkeypatch, rpm1) Loading tests/comparators/test_utils.py +6 −11 Original line number Diff line number Diff line Loading @@ -25,13 +25,8 @@ from diffoscope.difference import Difference from diffoscope.comparators.utils.command import Command from utils.data import data, load_fixture from utils.tools import tools_missing, skip_unless_tools_exist try: import tlsh # noqa miss_tlsh = False except ImportError: miss_tlsh = True from utils.tools import tools_missing, skip_unless_tools_exist, \ skip_unless_module_exists fuzzy_tar1 = load_fixture('fuzzy1.tar') Loading Loading @@ -62,7 +57,7 @@ def skip_unless_tool_is_at_least(): return '4.3-git' assert func('cat', version, '4.3').args[0] is False @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_fuzzy_matching(fuzzy_tar1, fuzzy_tar2): differences = fuzzy_tar1.compare(fuzzy_tar2).details expected_diff = codecs.open(data('text_iso8859_expected_diff'), encoding='utf-8').read() Loading @@ -71,7 +66,7 @@ def test_fuzzy_matching(fuzzy_tar1, fuzzy_tar2): assert 'similar' in differences[1].comment assert differences[1].unified_diff == expected_diff @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_fuzzy_matching_only_once(fuzzy_tar1, fuzzy_tar3): differences = fuzzy_tar1.compare(fuzzy_tar3).details assert len(differences) == 2 Loading @@ -79,14 +74,14 @@ def test_fuzzy_matching_only_once(fuzzy_tar1, fuzzy_tar3): fuzzy_tar_in_tar1 = load_fixture('fuzzy-tar-in-tar1.tar') fuzzy_tar_in_tar2 = load_fixture('fuzzy-tar-in-tar2.tar') @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_no_fuzzy_matching(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2): monkeypatch.setattr(Config(), 'fuzzy_threshold', 0) difference = fuzzy_tar_in_tar1.compare(fuzzy_tar_in_tar2) assert len(difference.details) == 1 assert difference.details[0].source1 == 'file list' @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_no_fuzzy_matching_new_file(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2): monkeypatch.setattr(Config(), 'fuzzy_threshold', 0) monkeypatch.setattr(Config(), 'new_file', True) Loading Loading
tests/comparators/test_debian.py +12 −12 Original line number Diff line number Diff line Loading @@ -27,16 +27,16 @@ from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.utils.specialize import specialize from utils.data import data, get_data from utils.tools import skip_unless_module_exists from utils.nonexisting import assert_non_existing try: from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \ DotBuildinfoFile miss_debian_module = False except ImportError: from diffoscope.comparators.debian_fallback import DotChangesFile, DotDscFile, \ DotBuildinfoFile miss_debian_module = True TEST_DOT_CHANGES_FILE1_PATH = data('test1.changes') TEST_DOT_CHANGES_FILE2_PATH = data('test2.changes') Loading Loading @@ -86,7 +86,7 @@ def dot_changes4(tmpdir): def test_dot_changes_identification(dot_changes1): assert isinstance(dot_changes1, DotChangesFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_invalid(tmpdir): tmpdir.mkdir('a') dot_changes_path = str(tmpdir.join('a/test_1.changes')) Loading Loading @@ -120,18 +120,18 @@ def dot_changes_differences_different_contents_and_identical_files(dot_changes2, difference = dot_changes4.compare(dot_changes2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_no_differences_exclude_buildinfo(dot_changes1, dot_changes3): difference = dot_changes1.compare(dot_changes3) assert difference is None @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_identical_contents_and_different_files(dot_changes_differences_identical_contents_and_different_files): assert dot_changes_differences_identical_contents_and_different_files[0] expected_diff = get_data('dot_changes_identical_contents_and_different_files_expected_diff') assert dot_changes_differences_identical_contents_and_different_files[0].unified_diff == expected_diff @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_changes_different_contents_and_identical_files(dot_changes_differences_different_contents_and_identical_files): assert dot_changes_differences_different_contents_and_identical_files[0] assert dot_changes_differences_different_contents_and_identical_files[1] Loading Loading @@ -165,7 +165,7 @@ def dot_dsc2(tmpdir): def test_dot_dsc_identification(dot_dsc1): assert isinstance(dot_dsc1, DotDscFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_invalid(tmpdir, dot_dsc2): tmpdir.mkdir('a') dot_dsc_path = str(tmpdir.join('a/test_1.dsc')) Loading @@ -183,11 +183,11 @@ def dot_dsc_differences(dot_dsc1, dot_dsc2): difference = dot_dsc1.compare(dot_dsc2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_internal_diff(dot_dsc_differences): assert dot_dsc_differences[1].source1 == 'test_1.tar.gz' @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_dsc_compare_non_existing(monkeypatch, dot_dsc1): monkeypatch.setattr(Config(), 'new_file', True) difference = dot_dsc1.compare(MissingFile('/nonexisting', dot_dsc1)) Loading Loading @@ -216,7 +216,7 @@ def dot_buildinfo2(tmpdir): def test_dot_buildinfo_identification(dot_buildinfo1): assert isinstance(dot_buildinfo1, DotBuildinfoFile) @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_invalid(tmpdir): tmpdir.mkdir('a') dot_buildinfo_path = str(tmpdir.join('a/test_1.buildinfo')) Loading @@ -234,11 +234,11 @@ def dot_buildinfo_differences(dot_buildinfo1, dot_buildinfo2): difference = dot_buildinfo1.compare(dot_buildinfo2) return difference.details @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_internal_diff(dot_buildinfo_differences): assert dot_buildinfo_differences[1].source1 == 'test_1_all.deb' @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_dot_buildinfo_compare_non_existing(monkeypatch, dot_buildinfo1): assert_non_existing(monkeypatch, dot_buildinfo1) Loading
tests/comparators/test_elf.py +3 −10 Original line number Diff line number Diff line Loading @@ -29,14 +29,7 @@ from diffoscope.comparators.utils.specialize import specialize from utils.data import data, load_fixture, get_data from utils.tools import skip_unless_tools_exist, \ skip_if_binutils_does_not_support_x86 try: import diffoscope.comparators.debian # noqa miss_debian_module = False except ImportError: miss_debian_module = True skip_if_binutils_does_not_support_x86, skip_unless_module_exists obj1 = load_fixture('test1.o') obj2 = load_fixture('test2.o') Loading Loading @@ -127,7 +120,7 @@ def dbgsym_differences(dbgsym_dir1, dbgsym_dir2): @skip_unless_tools_exist('readelf', 'objdump', 'objcopy') @skip_if_binutils_does_not_support_x86() @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_differences_with_dbgsym(dbgsym_differences): assert dbgsym_differences.details[2].source1 == 'data.tar.xz' bin_details = dbgsym_differences.details[2].details[0].details[0] Loading @@ -137,7 +130,7 @@ def test_differences_with_dbgsym(dbgsym_differences): @skip_unless_tools_exist('readelf', 'objdump', 'objcopy') @skip_if_binutils_does_not_support_x86() @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed') @skip_unless_module_exists('debian.deb822') def test_original_gnu_debuglink(dbgsym_differences): bin_details = dbgsym_differences.details[2].details[0].details[0] assert '.gnu_debuglink' in bin_details.details[2].source1 Loading
tests/comparators/test_fsimage.py +7 −12 Original line number Diff line number Diff line Loading @@ -24,20 +24,15 @@ from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.fsimage import FsImageFile from utils.data import load_fixture, get_data from utils.tools import skip_unless_tools_exist try: import guestfs miss_guestfs = False except ImportError: miss_guestfs = True from utils.tools import skip_unless_tools_exist, skip_unless_module_exists img1 = load_fixture('test1.ext4') img2 = load_fixture('test2.ext4') def guestfs_working(): if miss_guestfs: try: import guestfs except ImportError: return False g = guestfs.GuestFS (python_return_dict=True) g.add_drive_opts("/dev/null", format="raw", readonly=1) Loading @@ -52,7 +47,7 @@ def test_identification(img1): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_no_differences(img1): difference = img1.compare(img1) assert difference is None Loading @@ -63,7 +58,7 @@ def differences(img1, img2): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_differences(differences): assert differences[0].source1 == 'test1.ext4.tar' tarinfo = differences[0].details[0] Loading @@ -81,7 +76,7 @@ def test_differences(differences): @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system') @skip_unless_tools_exist('qemu-img') @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing') @skip_unless_module_exists('guestfs') def test_compare_non_existing(monkeypatch, img1): monkeypatch.setattr(Config(), 'new_file', True) difference = img1.compare(MissingFile('/nonexisting', img1)) Loading
tests/comparators/test_rpm.py +6 −8 Original line number Diff line number Diff line Loading @@ -24,16 +24,14 @@ from diffoscope.comparators.binary import FilesystemFile from diffoscope.comparators.utils.specialize import specialize from utils.data import load_fixture, data, get_data from utils.tools import skip_unless_tools_exist from utils.tools import skip_unless_tools_exist, skip_unless_module_exists from utils.nonexisting import assert_non_existing try: from diffoscope.comparators.rpm import RpmFile miss_rpm_module = False except ImportError: from diffoscope.comparators.rpm_fallback import RpmFile miss_rpm_module = True rpm1 = load_fixture('test1.rpm') rpm2 = load_fixture('test2.rpm') Loading @@ -41,7 +39,7 @@ rpm2 = load_fixture('test2.rpm') def test_identification(rpm1): assert isinstance(rpm1, RpmFile) @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') def test_no_differences(rpm1): difference = rpm1.compare(rpm1) assert difference is None Loading @@ -50,14 +48,14 @@ def test_no_differences(rpm1): def differences(rpm1, rpm2): return rpm1.compare(rpm2).details @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_header(differences): assert differences[0].source1 == 'header' expected_diff = get_data('rpm_header_expected_diff') assert differences[0].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_listing(differences): assert differences[1].source1 == 'content' Loading @@ -65,7 +63,7 @@ def test_listing(differences): expected_diff = get_data('rpm_listing_expected_diff') assert differences[1].details[0].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_content(differences): assert differences[1].source1 == 'content' Loading @@ -73,7 +71,7 @@ def test_content(differences): expected_diff = get_data('text_ascii_expected_diff') assert differences[1].details[1].unified_diff == expected_diff @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed') @skip_unless_module_exists('rpm') @skip_unless_tools_exist('rpm2cpio') def test_compare_non_existing(monkeypatch, rpm1): assert_non_existing(monkeypatch, rpm1) Loading
tests/comparators/test_utils.py +6 −11 Original line number Diff line number Diff line Loading @@ -25,13 +25,8 @@ from diffoscope.difference import Difference from diffoscope.comparators.utils.command import Command from utils.data import data, load_fixture from utils.tools import tools_missing, skip_unless_tools_exist try: import tlsh # noqa miss_tlsh = False except ImportError: miss_tlsh = True from utils.tools import tools_missing, skip_unless_tools_exist, \ skip_unless_module_exists fuzzy_tar1 = load_fixture('fuzzy1.tar') Loading Loading @@ -62,7 +57,7 @@ def skip_unless_tool_is_at_least(): return '4.3-git' assert func('cat', version, '4.3').args[0] is False @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_fuzzy_matching(fuzzy_tar1, fuzzy_tar2): differences = fuzzy_tar1.compare(fuzzy_tar2).details expected_diff = codecs.open(data('text_iso8859_expected_diff'), encoding='utf-8').read() Loading @@ -71,7 +66,7 @@ def test_fuzzy_matching(fuzzy_tar1, fuzzy_tar2): assert 'similar' in differences[1].comment assert differences[1].unified_diff == expected_diff @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_fuzzy_matching_only_once(fuzzy_tar1, fuzzy_tar3): differences = fuzzy_tar1.compare(fuzzy_tar3).details assert len(differences) == 2 Loading @@ -79,14 +74,14 @@ def test_fuzzy_matching_only_once(fuzzy_tar1, fuzzy_tar3): fuzzy_tar_in_tar1 = load_fixture('fuzzy-tar-in-tar1.tar') fuzzy_tar_in_tar2 = load_fixture('fuzzy-tar-in-tar2.tar') @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_no_fuzzy_matching(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2): monkeypatch.setattr(Config(), 'fuzzy_threshold', 0) difference = fuzzy_tar_in_tar1.compare(fuzzy_tar_in_tar2) assert len(difference.details) == 1 assert difference.details[0].source1 == 'file list' @pytest.mark.skipif(miss_tlsh, reason='tlsh is missing') @skip_unless_module_exists('tlsh') def test_no_fuzzy_matching_new_file(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2): monkeypatch.setattr(Config(), 'fuzzy_threshold', 0) monkeypatch.setattr(Config(), 'new_file', True) Loading