Skip to content

Commit

Permalink
Fix tests using list --json results
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Feb 25, 2020
1 parent 607dbea commit 317b187
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
44 changes: 30 additions & 14 deletions tests/functional/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ def test_uptodate_flag(script, data):
'list', '-f', data.find_links, '--no-index', '--uptodate',
'--format=json',
)
assert {"name": "simple", "version": "1.0"} \
not in json.loads(result.stdout) # 3.0 is latest
assert {"name": "pip-test-package", "version": "0.1.1"} \
in json.loads(result.stdout) # editables included
assert {"name": "simple2", "version": "3.0"} in json.loads(result.stdout)
json_result = json.loads(result.stdout)

# 3.0 is latest
assert "simple" not in {d["name"] for d in json_result}
# editables included
assert {
"name": "pip-test-package",
"version": "0.1.1",
"location": str(script.venv_path / "src" / "pip-test-package"),
} in json_result
assert {"name": "simple2", "version": "3.0"} in json_result


@pytest.mark.network
Expand Down Expand Up @@ -198,15 +204,25 @@ def test_outdated_flag(script, data):
'list', '-f', data.find_links, '--no-index', '--outdated',
'--format=json',
)
assert {"name": "simple", "version": "1.0",
"latest_version": "3.0", "latest_filetype": "sdist"} \
in json.loads(result.stdout)
assert dict(name="simplewheel", version="1.0",
latest_version="2.0", latest_filetype="wheel") \
in json.loads(result.stdout)
assert dict(name="pip-test-package", version="0.1",
latest_version="0.1.1", latest_filetype="sdist") \
in json.loads(result.stdout)
assert {
"name": "simple",
"version": "1.0",
"latest_version": "3.0",
"latest_filetype": "sdist",
} in json.loads(result.stdout)
assert {
"name": "simplewheel",
"version": "1.0",
"latest_version": "2.0",
"latest_filetype": "wheel",
} in json.loads(result.stdout)
assert {
"name": "pip-test-package",
"version": "0.1",
"location": str(script.venv_path / "src" / "pip-test-package"),
"latest_version": "0.1.1",
"latest_filetype": "sdist",
} in json.loads(result.stdout)
assert "simple2" not in {p["name"] for p in json.loads(result.stdout)}


Expand Down
17 changes: 13 additions & 4 deletions tests/functional/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,14 @@ def test_uninstall_setuptools_develop_install(script, data):
script.run('python', 'setup.py', 'install',
expect_stderr=True, cwd=pkg_path)
list_result = script.pip('list', '--format=json')
assert {"name": os.path.normcase("FSPkg"), "version": "0.1.dev0"} \
in json.loads(list_result.stdout), str(list_result)
assert {
"name": os.path.normcase("FSPkg"),
"version": "0.1.dev0",
"location": str(
script.site_packages_path /
"FSPkg-0.1.dev0-py{0}.{1}.egg".format(*sys.version_info)
),
} in json.loads(list_result.stdout), str(list_result)
# Uninstall both develop and install
uninstall = script.pip('uninstall', 'FSPkg', '-y')
assert any(filename.endswith('.egg')
Expand All @@ -538,8 +544,11 @@ def test_uninstall_editable_and_pip_install(script, data):
script.pip('install', '--ignore-installed', '.',
expect_stderr=True, cwd=pkg_path)
list_result = script.pip('list', '--format=json')
assert {"name": "FSPkg", "version": "0.1.dev0"} \
in json.loads(list_result.stdout)
assert {
"name": "FSPkg",
"version": "0.1.dev0",
"location": str(script.site_packages_path),
} in json.loads(list_result.stdout)
# Uninstall both develop and install
uninstall = script.pip('uninstall', 'FSPkg', '-y')
assert not any(filename.endswith('.egg-link')
Expand Down

0 comments on commit 317b187

Please sign in to comment.