How to use diffoscope - 10 common examples

To help you get started, we’ve selected a few diffoscope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anthraxx / diffoscope / tests / comparators / test_icc.py View on Github external
def test_compare_non_existing(monkeypatch, icc1):
    monkeypatch.setattr(Config(), 'new_file', True)
    difference = icc1.compare(MissingFile('/nonexisting', icc1))
    assert difference.source2 == '/nonexisting'
    assert len(difference.details) > 0
github anthraxx / diffoscope / tests / comparators / test_macho.py View on Github external
def test_obj_compare_non_existing(monkeypatch, obj1):
    monkeypatch.setattr(Config(), 'new_file', True)
    difference = obj1.compare(MissingFile('/nonexisting', obj1))
    assert difference.source2 == '/nonexisting'
    assert len(difference.details) > 0
github anthraxx / diffoscope / tests / comparators / test_fonts.py View on Github external
def test_compare_non_existing(monkeypatch, ttf1):
    monkeypatch.setattr(Config(), 'new_file', True)
    difference = ttf1.compare(MissingFile('/nonexisting', ttf1))
    assert difference.source2 == '/nonexisting'
    assert len(difference.details) > 0
github anthraxx / diffoscope / tests / test_difference.py View on Github external
def test_too_long_diff_block_lines(monkeypatch):
    monkeypatch.setattr(Config(), 'enforce_constraints', False)
    monkeypatch.setattr(Config(), 'max_diff_block_lines_saved', 10)
    too_long_text_a = io.StringIO("a\n" * 21)
    too_long_text_b = io.StringIO("b\n" * 21)
    difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, 'a', 'b')
    assert '[ 11 lines removed ]' in difference.unified_diff
github anthraxx / diffoscope / tests / comparators / test_utils.py View on Github external
def test_trim_stderr_in_command():
    class FillStderr(Command):
        def cmdline(self):
            return ['tee', '/dev/stderr']

        def feed_stdin(self, stdin):
            for dummy in range(0, Command.MAX_STDERR_LINES + 1):
                stdin.write('error {}\n'.format(self.path).encode('utf-8'))
    difference = Difference.from_command(FillStderr, 'dummy1', 'dummy2')
    assert '[ 1 lines ignored ]' in difference.comment
github anthraxx / diffoscope / tests / comparators / test_rpm.py View on Github external
def test_fallback_comparison(monkeypatch):
    manager = ComparatorManager()
    monkeypatch.setattr(manager, 'COMPARATORS', (
        ('rpm_fallback.RpmFile',),
    ))
    manager.reload()

    # Re-specialize after reloading our Comparators
    rpm1 = specialize(FilesystemFile(data('test1.rpm')))
    rpm2 = specialize(FilesystemFile(data('test2.rpm')))

    assert rpm1.compare(rpm1) is None
    assert rpm2.compare(rpm2) is None

    expected_diff = get_data('rpm_fallback_expected_diff')
    assert normalize_zeros(rpm1.compare(rpm2).unified_diff) == expected_diff
github anthraxx / diffoscope / tests / comparators / test_debian.py View on Github external
def test_dot_buildinfo_invalid(tmpdir):
    tmpdir.mkdir('a')
    dot_buildinfo_path = str(tmpdir.join('a/test_1.buildinfo'))
    shutil.copy(TEST_DOT_BUILDINFO_FILE1_PATH, dot_buildinfo_path)
    # we don't copy the referenced .deb
    identified = specialize(FilesystemFile(dot_buildinfo_path))
    assert not isinstance(identified, DotBuildinfoFile)
github anthraxx / diffoscope / tests / comparators / test_gzip.py View on Github external
def test_content_source_without_extension(tmpdir, gzip1, gzip2):
    path1 = str(tmpdir.join('test1'))
    path2 = str(tmpdir.join('test2'))
    shutil.copy(gzip1.path, path1)
    shutil.copy(gzip2.path, path2)
    gzip1 = specialize(FilesystemFile(path1))
    gzip2 = specialize(FilesystemFile(path2))
    difference = gzip1.compare(gzip2).details
    assert difference[1].source1 == 'test1-content'
    assert difference[1].source2 == 'test2-content'
github anthraxx / diffoscope / tests / comparators / test_elf.py View on Github external
def lib1():
    return specialize(FilesystemFile(TEST_LIB1_PATH))
github anthraxx / diffoscope / tests / comparators / test_elf.py View on Github external
def lib2():
    return specialize(FilesystemFile(TEST_LIB2_PATH))