Skip to content

Commit 317b187

Browse files
committed
Fix tests using list --json results
1 parent 607dbea commit 317b187

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
@@ -146,11 +146,17 @@ def test_uptodate_flag(script, data):
146146
'list', '-f', data.find_links, '--no-index', '--uptodate',
147147
'--format=json',
148148
)
149-
assert {"name": "simple", "version": "1.0"} \
150-
not in json.loads(result.stdout) # 3.0 is latest
151-
assert {"name": "pip-test-package", "version": "0.1.1"} \
152-
in json.loads(result.stdout) # editables included
153-
assert {"name": "simple2", "version": "3.0"} in json.loads(result.stdout)
149+
json_result = json.loads(result.stdout)
150+
151+
# 3.0 is latest
152+
assert "simple" not in {d["name"] for d in json_result}
153+
# editables included
154+
assert {
155+
"name": "pip-test-package",
156+
"version": "0.1.1",
157+
"location": str(script.venv_path / "src" / "pip-test-package"),
158+
} in json_result
159+
assert {"name": "simple2", "version": "3.0"} in json_result
154160

155161

156162
@pytest.mark.network
@@ -198,15 +204,25 @@ def test_outdated_flag(script, data):
198204
'list', '-f', data.find_links, '--no-index', '--outdated',
199205
'--format=json',
200206
)
201-
assert {"name": "simple", "version": "1.0",
202-
"latest_version": "3.0", "latest_filetype": "sdist"} \
203-
in json.loads(result.stdout)
204-
assert dict(name="simplewheel", version="1.0",
205-
latest_version="2.0", latest_filetype="wheel") \
206-
in json.loads(result.stdout)
207-
assert dict(name="pip-test-package", version="0.1",
208-
latest_version="0.1.1", latest_filetype="sdist") \
209-
in json.loads(result.stdout)
207+
assert {
208+
"name": "simple",
209+
"version": "1.0",
210+
"latest_version": "3.0",
211+
"latest_filetype": "sdist",
212+
} in json.loads(result.stdout)
213+
assert {
214+
"name": "simplewheel",
215+
"version": "1.0",
216+
"latest_version": "2.0",
217+
"latest_filetype": "wheel",
218+
} in json.loads(result.stdout)
219+
assert {
220+
"name": "pip-test-package",
221+
"version": "0.1",
222+
"location": str(script.venv_path / "src" / "pip-test-package"),
223+
"latest_version": "0.1.1",
224+
"latest_filetype": "sdist",
225+
} in json.loads(result.stdout)
210226
assert "simple2" not in {p["name"] for p in json.loads(result.stdout)}
211227

212228

tests/functional/test_uninstall.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,14 @@ def test_uninstall_setuptools_develop_install(script, data):
510510
script.run('python', 'setup.py', 'install',
511511
expect_stderr=True, cwd=pkg_path)
512512
list_result = script.pip('list', '--format=json')
513-
assert {"name": os.path.normcase("FSPkg"), "version": "0.1.dev0"} \
514-
in json.loads(list_result.stdout), str(list_result)
513+
assert {
514+
"name": os.path.normcase("FSPkg"),
515+
"version": "0.1.dev0",
516+
"location": str(
517+
script.site_packages_path /
518+
"FSPkg-0.1.dev0-py{0}.{1}.egg".format(*sys.version_info)
519+
),
520+
} in json.loads(list_result.stdout), str(list_result)
515521
# Uninstall both develop and install
516522
uninstall = script.pip('uninstall', 'FSPkg', '-y')
517523
assert any(filename.endswith('.egg')
@@ -538,8 +544,11 @@ def test_uninstall_editable_and_pip_install(script, data):
538544
script.pip('install', '--ignore-installed', '.',
539545
expect_stderr=True, cwd=pkg_path)
540546
list_result = script.pip('list', '--format=json')
541-
assert {"name": "FSPkg", "version": "0.1.dev0"} \
542-
in json.loads(list_result.stdout)
547+
assert {
548+
"name": "FSPkg",
549+
"version": "0.1.dev0",
550+
"location": str(script.site_packages_path),
551+
} in json.loads(list_result.stdout)
543552
# Uninstall both develop and install
544553
uninstall = script.pip('uninstall', 'FSPkg', '-y')
545554
assert not any(filename.endswith('.egg-link')

0 commit comments

Comments
 (0)