Skip to content

Commit 24a2dda

Browse files
committed
Fixed line count in 'pip show' tests. Renamed 'pip.util.recursive_dependencies()' to 'pip.util.get_recursive_dependencies()'. This function now takes a list of positional arguments (was a list as first positional argument).
1 parent cc94c3a commit 24a2dda

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

pip/commands/freeze.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pip.req import InstallRequirement
77
from pip.log import logger
88
from pip.basecommand import Command
9-
from pip.util import get_installed_distributions, recursive_dependencies
9+
from pip.util import get_installed_distributions, get_recursive_dependencies
1010

1111

1212
# packages to exclude from freeze output
@@ -77,7 +77,7 @@ def run(self, options, args):
7777
only_dists = []
7878
if args:
7979
only_dists = args
80-
only_dists.extend(recursive_dependencies(only_dists))
80+
only_dists.extend(get_recursive_dependencies(*only_dists))
8181
only_dists = [name.lower() for name in only_dists]
8282

8383
for dist in get_installed_distributions(local_only=local_only,

pip/commands/show.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pip.basecommand import Command
44
from pip.log import logger
5-
from pip.util import recursive_dependencies
5+
from pip.util import get_recursive_dependencies
66
from pip._vendor import pkg_resources
77

88

@@ -80,7 +80,7 @@ def print_results(distributions, list_all_files):
8080
logger.notify("Location: %s" % dist['location'])
8181
logger.notify("Requires: %s" % ', '.join(dist['requires']))
8282
logger.notify("Requires recursive: %s" % ', '.join(
83-
recursive_dependencies([dist['name']])))
83+
get_recursive_dependencies(dist['name'])))
8484
if list_all_files:
8585
logger.notify("Files:")
8686
if dist['files'] is not None:

pip/util.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,22 @@ def get_installed_distributions(local_only=True,
400400
]
401401

402402

403-
def recursive_dependencies(query):
404-
"""Return list of dependencies of dists in ``query``, recursively."""
403+
def get_recursive_dependencies(*names):
404+
"""Return set of dependencies of dists in ``names``, recursively."""
405405
dependencies = set()
406406
installed = dict(
407407
[(p.project_name.lower(), p) for p in pkg_resources.working_set])
408-
query_names = [name.lower() for name in query]
408+
query_names = [name.lower() for name in names]
409409
for pkg in query_names:
410410
try:
411411
dist = installed[pkg]
412-
for dep in dist.requires():
413-
dependencies.add(dep.project_name)
414-
dependencies.update(recursive_dependencies([dep.project_name]))
415412
except KeyError:
416413
pass # pkg is not installed.
414+
else:
415+
for dep in dist.requires():
416+
name = dep.project_name
417+
dependencies.add(name)
418+
dependencies.update(get_recursive_dependencies(name))
417419
return dependencies
418420

419421

tests/functional/test_show.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_show(script):
99
"""
1010
result = script.pip('show', 'pip')
1111
lines = result.stdout.split('\n')
12-
assert len(lines) == 6
12+
assert len(lines) == 7
1313
assert lines[0] == '---', lines[0]
1414
assert lines[1] == 'Name: pip', lines[1]
1515
assert lines[2] == 'Version: %s' % __version__, lines[2]
@@ -27,7 +27,7 @@ def test_show_with_files_not_found(script, data):
2727
script.pip('install', '-e', editable)
2828
result = script.pip('show', '-f', 'SetupPyUTF8')
2929
lines = result.stdout.split('\n')
30-
assert len(lines) == 8
30+
assert len(lines) == 9
3131
assert lines[0] == '---', lines[0]
3232
assert lines[1] == 'Name: SetupPyUTF8', lines[1]
3333
assert lines[2] == 'Version: 0.0.0', lines[2]

0 commit comments

Comments
 (0)