How to use the diffoscope.comparators.binary.FilesystemFile function in diffoscope

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_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_bzip2.py View on Github external
def test_content_source_without_extension(tmpdir, bzip1, bzip2):
    path1 = str(tmpdir.join('test1'))
    path2 = str(tmpdir.join('test2'))
    shutil.copy(bzip1.path, path1)
    shutil.copy(bzip2.path, path2)
    bzip1 = specialize(FilesystemFile(path1))
    bzip2 = specialize(FilesystemFile(path2))
    differences = bzip1.compare(bzip2).details
    assert differences[0].source1 == 'test1-content'
    assert differences[0].source2 == 'test2-content'
github anthraxx / diffoscope / tests / comparators / test_deb.py View on Github external
def test_identification_of_md5sums_outside_deb(tmpdir):
    path = str(tmpdir.join('md5sums'))
    open(path, 'w')
    f = specialize(FilesystemFile(path))
    assert type(f) is FilesystemFile
github anthraxx / diffoscope / tests / comparators / test_debian.py View on Github external
def dot_dsc1(tmpdir):
    tmpdir.mkdir('a')
    dot_dsc_path = str(tmpdir.join('a/test_1.dsc'))
    shutil.copy(TEST_DOT_DSC_FILE1_PATH, dot_dsc_path)
    shutil.copy(TEST_DEB_SRC1_PATH, str(tmpdir.join('a/test_1.tar.gz')))
    return specialize(FilesystemFile(dot_dsc_path))
github anthraxx / diffoscope / tests / comparators / test_haskell.py View on Github external
def test_identification(haskell1):
    if isinstance(haskell1, FilesystemFile):
        pytest.skip("mismatch between system ghc and fixture")

    assert isinstance(haskell1, HiFile)
github anthraxx / diffoscope / tests / comparators / test_debian.py View on Github external
def dot_dsc2(tmpdir):
    tmpdir.mkdir('b')
    dot_dsc_path = str(tmpdir.join('b/test_1.dsc'))
    shutil.copy(TEST_DOT_DSC_FILE2_PATH, dot_dsc_path)
    shutil.copy(TEST_DEB_SRC2_PATH, str(tmpdir.join('b/test_1.tar.gz')))
    return specialize(FilesystemFile(dot_dsc_path))
github anthraxx / diffoscope / tests / comparators / test_binary.py View on Github external
def test_with_compare_details_and_no_actual_differences():
    class MockFile(FilesystemFile):
        def compare_details(self, other, source=None):
            return []
    difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE1_PATH))
    assert difference is None
github anthraxx / diffoscope / tests / comparators / test_directory.py View on Github external
def test_compare_to_dangling_symlink(tmpdir):
    path = str(tmpdir.join('src'))
    os.symlink('/dangling', path)

    a = specialize(FilesystemFile(str(tmpdir.mkdir('dir'))))
    b = specialize(FilesystemFile(path))

    assert a.compare(b).unified_diff == get_data('test_directory_symlink_diff')
github anthraxx / diffoscope / diffoscope / comparators / directory.py View on Github external
def get_member(self, member_name):
        member_path = os.path.join(self.source.path, member_name)
        if not os.path.islink(member_path) and os.path.isdir(member_path):
            return FilesystemDirectory(member_path)
        else:
            return FilesystemFile(os.path.join(self.source.path, member_name), container=self)