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_conflicting_deps():
# the custom environment has a bad jinja version and it's missing simplejson
_, _, conflicting_tree = venv_fixture('tests/virtualenvs/unsatisfiedenv.pickle')
flask = next((x for x in conflicting_tree.keys() if x.key == 'flask'))
jinja = next((x for x in conflicting_tree[flask] if x.key == 'jinja2'))
uritemplate = next((x for x in conflicting_tree.keys() if x.key == 'uritemplate'))
simplejson = next((x for x in conflicting_tree[uritemplate] if x.key == 'simplejson'))
assert jinja
assert flask
assert uritemplate
assert simplejson
unsatisfied = conflicting_deps(conflicting_tree)
assert unsatisfied == {
flask: [jinja],
uritemplate: [simplejson],
}
def get_conflicting_dependencies(tree):
"""Returns sorted conflicting dependencies
:param tree: dictionary of dependencies
:return: sorted dict of conflicting dependencies
"""
conflicting_dependencies = dict(pipdeptree.conflicting_deps(tree))
if conflicting_dependencies:
conflicting_data = []
for package in sorted(conflicting_dependencies, key=lambda p: p.key):
for dependency in sorted(
conflicting_dependencies[package], key=lambda d: d.key):
conflicting_data.append([
printer.printable_package(dependency.key),
package.key,
get_required_package_version(dependency),
get_installed_package_version(dependency),
])
return conflicting_data