Skip to content

Commit 8ef46c8

Browse files
committed
Fix tests using list --json results
1 parent 53494c6 commit 8ef46c8

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

tests/functional/test_list.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,17 @@ def test_uptodate_flag(script, data):
160160
'list', '-f', data.find_links, '--no-index', '--uptodate',
161161
'--format=json',
162162
)
163-
assert {"name": "simple", "version": "1.0"} \
164-
not in json.loads(result.stdout) # 3.0 is latest
165-
assert {"name": "pip-test-package", "version": "0.1.1"} \
166-
in json.loads(result.stdout) # editables included
167-
assert {"name": "simple2", "version": "3.0"} in json.loads(result.stdout)
163+
json_result = json.loads(result.stdout)
164+
165+
# 3.0 is latest
166+
assert "simple" not in {d["name"] for d in json_result}
167+
# editables included
168+
assert {
169+
"name": "pip-test-package",
170+
"version": "0.1.1",
171+
"location": str(script.venv_path / "src" / "pip-test-package"),
172+
} in json_result
173+
assert {"name": "simple2", "version": "3.0"} in json_result
168174

169175

170176
@pytest.mark.network
@@ -212,15 +218,25 @@ def test_outdated_flag(script, data):
212218
'list', '-f', data.find_links, '--no-index', '--outdated',
213219
'--format=json',
214220
)
215-
assert {"name": "simple", "version": "1.0",
216-
"latest_version": "3.0", "latest_filetype": "sdist"} \
217-
in json.loads(result.stdout)
218-
assert dict(name="simplewheel", version="1.0",
219-
latest_version="2.0", latest_filetype="wheel") \
220-
in json.loads(result.stdout)
221-
assert dict(name="pip-test-package", version="0.1",
222-
latest_version="0.1.1", latest_filetype="sdist") \
223-
in json.loads(result.stdout)
221+
assert {
222+
"name": "simple",
223+
"version": "1.0",
224+
"latest_version": "3.0",
225+
"latest_filetype": "sdist",
226+
} in json.loads(result.stdout)
227+
assert {
228+
"name": "simplewheel",
229+
"version": "1.0",
230+
"latest_version": "2.0",
231+
"latest_filetype": "wheel",
232+
} in json.loads(result.stdout)
233+
assert {
234+
"name": "pip-test-package",
235+
"version": "0.1",
236+
"location": str(script.venv_path / "src" / "pip-test-package"),
237+
"latest_version": "0.1.1",
238+
"latest_filetype": "sdist",
239+
} in json.loads(result.stdout)
224240
assert "simple2" not in {p["name"] for p in json.loads(result.stdout)}
225241

226242

tests/functional/test_uninstall.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,14 @@ def test_uninstall_setuptools_develop_install(script, data):
506506
script.run('python', 'setup.py', 'install',
507507
expect_stderr=True, cwd=pkg_path)
508508
list_result = script.pip('list', '--format=json')
509-
assert {"name": os.path.normcase("FSPkg"), "version": "0.1.dev0"} \
510-
in json.loads(list_result.stdout), str(list_result)
509+
assert {
510+
"name": os.path.normcase("FSPkg"),
511+
"version": "0.1.dev0",
512+
"location": str(
513+
script.site_packages_path /
514+
"FSPkg-0.1.dev0-py{0}.{1}.egg".format(*sys.version_info)
515+
),
516+
} in json.loads(list_result.stdout), str(list_result)
511517
# Uninstall both develop and install
512518
uninstall = script.pip('uninstall', 'FSPkg', '-y')
513519
assert any(filename.endswith('.egg')
@@ -534,8 +540,11 @@ def test_uninstall_editable_and_pip_install(script, data):
534540
script.pip('install', '--ignore-installed', '.',
535541
expect_stderr=True, cwd=pkg_path)
536542
list_result = script.pip('list', '--format=json')
537-
assert {"name": "FSPkg", "version": "0.1.dev0"} \
538-
in json.loads(list_result.stdout)
543+
assert {
544+
"name": "FSPkg",
545+
"version": "0.1.dev0",
546+
"location": str(script.site_packages_path),
547+
} in json.loads(list_result.stdout)
539548
# Uninstall both develop and install
540549
uninstall = script.pip('uninstall', 'FSPkg', '-y')
541550
assert not any(filename.endswith('.egg-link')

0 commit comments

Comments
 (0)