Beispiel #1
0
def test_fallback_comparisons(monkeypatch):
    manager = ComparatorManager()
    monkeypatch.setattr(
        manager,
        'COMPARATORS',
        (
            ('debian_fallback.DotChangesFile', ),
            ('debian_fallback.DotDscFile', ),
            ('debian_fallback.DotBuildinfoFile', ),
        ),
    )
    manager.reload()

    for a, b, expected_diff in (
        (
            'test1.changes',
            'test2.changes',
            'dot_changes_fallback_expected_diff',
        ),
        ('test1.dsc', 'test2.dsc', 'dot_dsc_fallback_expected_diff'),
        (
            'test1.buildinfo',
            'test2.buildinfo',
            'dot_buildinfo_fallback_expected_diff',
        ),
    ):
        # Re-specialize after reloading our Comparators
        file1 = specialize(FilesystemFile(data(a)))
        file2 = specialize(FilesystemFile(data(b)))

        assert file1.compare(file1) is None
        assert file2.compare(file2) is None
        assert file1.compare(file2).unified_diff == get_data(expected_diff)
Beispiel #2
0
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
Beispiel #3
0
def _add_diffoscope_info(d):
    """Add diffoscope setup metadata to provided dict under 'diffoscope' key

    The imports are broken out at stages since various versions of
    diffoscope support various parts of these.

    """
    try:
        import diffoscope
        d['diffoscope'] = hashabledict()
        d['diffoscope']['VERSION'] = diffoscope.VERSION

        from diffoscope.comparators import ComparatorManager
        ComparatorManager().reload()

        from diffoscope.tools import tool_check_installed, tool_required
        external_tools = sorted(tool_required.all)
        external_tools = [
            tool
            for tool in external_tools
            if not tool_check_installed(tool)
        ]
        d['diffoscope']['External-Tools-Required'] = tuple(external_tools)

        from diffoscope.tools import OS_NAMES, get_current_os
        from diffoscope.external_tools import EXTERNAL_TOOLS
        current_os = get_current_os()
        os_list = [current_os] if (current_os in OS_NAMES) else iter(OS_NAMES)
        for os_ in os_list:
            tools = set()
            for x in external_tools:
                try:
                    tools.add(EXTERNAL_TOOLS[x][os_])
                except KeyError:
                    pass
            d['diffoscope']['Available-in-{}-packages'.format(OS_NAMES[os_])] = tuple(sorted(tools))

        from diffoscope.tools import python_module_missing
        d['diffoscope']['Missing-Python-Modules'] = tuple(sorted(python_module_missing.modules))
    except ImportError:
        pass
Beispiel #4
0
def reload_comparators():
    # Reload Comparators after every test so we are always in a consistent
    # state
    ComparatorManager().reload()