Beispiel #1
0
def test_cyclic_deps(capsys, mpkgs, expected_keys, expected_output):
    tree = mock_PackageDAG(mpkgs)
    result = p.cyclic_deps(tree)
    result_keys = [(a.key, b.key, c.key) for (a, b, c) in result]
    assert sorted(expected_keys) == sorted(result_keys)
    p.render_cycles_text(result)
    captured = capsys.readouterr()
    assert '\n'.join(expected_output).strip() == captured.err.strip()
Beispiel #2
0
def test_cyclic_dependencies():
    cyclic_pkgs, dist_index, tree = venv_fixture('tests/virtualenvs/cyclicenv.pickle')
    cyclic = [map(attrgetter('key'), cs) for cs in cyclic_deps(tree)]
    assert len(cyclic) == 2
    a, b, c = cyclic[0]
    x, y, z = cyclic[1]
    assert a == c == y
    assert x == z == b
def test_cyclic_dependencies():
    cyclic_pkgs, dist_index, tree = venv_fixture('tests/virtualenvs/cyclicenv.pickle')
    cyclic = [map(attrgetter('key'), cs) for cs in cyclic_deps(tree)]
    assert len(cyclic) == 2
    a, b, c = cyclic[0]
    x, y, z = cyclic[1]
    assert a == c == y
    assert x == z == b
Beispiel #4
0
def get_cyclic_dependencies(tree):
    """Returns sorted cyclic dependencies
    :param tree: dictionary of dependencies
    :return: sorted dict of cyclic dependencies
    """
    cyclic_dependencies = dict(pipdeptree.cyclic_deps(tree))

    if cyclic_dependencies:
        cyclic_data = []
        for package in sorted(cyclic_dependencies, key=lambda p: p.key):
            for dependency in sorted(cyclic_dependencies[package],
                                     key=lambda d: d.key):
                cyclic_data.append([
                    printer.printable_package(dependency.key), package.key,
                    get_required_package_version(dependency),
                    get_installed_package_version(dependency)
                ])
        return cyclic_data