Skip to content

Commit bb896cb

Browse files
committed
Add functional test for 'list --no-deps-only' option.
1 parent 60429a6 commit bb896cb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pip/commands/list.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,10 @@ def get_uptodate(self, packages, options):
183183
]
184184

185185
def get_nodeps_only(self, packages, options):
186-
installed_pkgs = [
187-
dist for dist in self.iter_packages_latest_infos(packages, options)
188-
]
189186
dep_keys = set()
190-
for dist in installed_pkgs:
187+
for dist in packages:
191188
dep_keys.update(requirement.key for requirement in dist.requires())
192-
return set(pkg for pkg in installed_pkgs if pkg.key not in dep_keys)
189+
return set(pkg for pkg in packages if pkg.key not in dep_keys)
193190

194191
def iter_packages_latest_infos(self, packages, options):
195192
index_urls = [options.index_url] + options.extra_index_urls

tests/functional/test_list.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@ def test_outdated_formats(script, data):
564564
'latest_version': '1.1', 'latest_filetype': 'wheel'}]
565565

566566

567+
def test_no_deps_only_flag(script, data):
568+
script.pip(
569+
'install', '-f', data.find_links, '--no-index', 'TopoRequires4'
570+
)
571+
result = script.pip('list', '--no-deps-only', expect_stderr=True)
572+
assert 'TopoRequires4 ' in result.stdout, str(result)
573+
assert 'TopoRequires ' not in result.stdout
574+
assert 'TopoRequires2 ' not in result.stdout
575+
assert 'TopoRequires3 ' not in result.stdout
576+
577+
567578
def test_list_freeze(script, data):
568579
"""
569580
Test freeze formatting of list command

0 commit comments

Comments
 (0)