Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 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