未验证 提交 ca439016 编写于 作者: S Stéphane Bidoul 提交者: GitHub

Merge pull request #8370 from ssurbhi560/add_method_to_new_resolver_and_download

Add methods for path lookups in test_download.py and test_new_resolver.py
......@@ -27,9 +27,10 @@ def test_download_if_requested(script):
result = script.pip(
'download', '-d', 'pip_downloads', 'INITools==0.1'
)
assert Path('scratch') / 'pip_downloads' / 'INITools-0.1.tar.gz' \
in result.files_created
assert script.site_packages / 'initools' not in result.files_created
result.did_create(
Path('scratch') / 'pip_downloads' / 'INITools-0.1.tar.gz'
)
result.did_not_create(script.site_packages / 'initools')
@pytest.mark.network
......@@ -54,11 +55,8 @@ def test_download_wheel(script, data):
'-f', data.packages,
'-d', '.', 'meta'
)
assert (
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl'
in result.files_created
)
assert script.site_packages / 'piptestpackage' not in result.files_created
result.did_create(Path('scratch') / 'meta-1.0-py2.py3-none-any.whl')
result.did_not_create(script.site_packages / 'piptestpackage')
@pytest.mark.network
......@@ -73,8 +71,8 @@ def test_single_download_from_requirements_file(script):
result = script.pip(
'download', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
result.did_create(Path('scratch') / 'INITools-0.1.tar.gz')
result.did_not_create(script.site_packages / 'initools')
@pytest.mark.network
......@@ -85,12 +83,12 @@ def test_basic_download_should_download_dependencies(script):
result = script.pip(
'download', 'Paste[openid]==1.7.5.1', '-d', '.'
)
assert Path('scratch') / 'Paste-1.7.5.1.tar.gz' in result.files_created
result.did_create(Path('scratch') / 'Paste-1.7.5.1.tar.gz')
openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
assert any(
path.startswith(openid_tarball_prefix) for path in result.files_created
)
assert script.site_packages / 'openid' not in result.files_created
result.did_not_create(script.site_packages / 'openid')
def test_download_wheel_archive(script, data):
......@@ -103,7 +101,7 @@ def test_download_wheel_archive(script, data):
'download', wheel_path,
'-d', '.', '--no-deps'
)
assert Path('scratch') / wheel_filename in result.files_created
result.did_create(Path('scratch') / wheel_filename)
def test_download_should_download_wheel_deps(script, data):
......@@ -117,8 +115,8 @@ def test_download_should_download_wheel_deps(script, data):
'download', wheel_path,
'-d', '.', '--find-links', data.find_links, '--no-index'
)
assert Path('scratch') / wheel_filename in result.files_created
assert Path('scratch') / dep_filename in result.files_created
result.did_create(Path('scratch') / wheel_filename)
result.did_create(Path('scratch') / dep_filename)
@pytest.mark.network
......@@ -133,8 +131,8 @@ def test_download_should_skip_existing_files(script):
result = script.pip(
'download', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
result.did_create(Path('scratch') / 'INITools-0.1.tar.gz')
result.did_not_create(script.site_packages / 'initools')
# adding second package to test-req.txt
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
......@@ -150,9 +148,9 @@ def test_download_should_skip_existing_files(script):
assert any(
path.startswith(openid_tarball_prefix) for path in result.files_created
)
assert Path('scratch') / 'INITools-0.1.tar.gz' not in result.files_created
assert script.site_packages / 'initools' not in result.files_created
assert script.site_packages / 'openid' not in result.files_created
result.did_not_create(Path('scratch') / 'INITools-0.1.tar.gz')
result.did_not_create(script.site_packages / 'initools')
result.did_not_create(script.site_packages / 'openid')
@pytest.mark.network
......@@ -163,11 +161,8 @@ def test_download_vcs_link(script):
result = script.pip(
'download', '-d', '.', 'git+git://github.com/pypa/pip-test-package.git'
)
assert (
Path('scratch') / 'pip-test-package-0.1.1.zip'
in result.files_created
)
assert script.site_packages / 'piptestpackage' not in result.files_created
result.did_create(Path('scratch') / 'pip-test-package-0.1.1.zip')
result.did_not_create(script.site_packages / 'piptestpackage')
def test_only_binary_set_then_download_specific_platform(script, data):
......@@ -184,10 +179,7 @@ def test_only_binary_set_then_download_specific_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
def test_no_deps_set_then_download_specific_platform(script, data):
......@@ -204,10 +196,7 @@ def test_no_deps_set_then_download_specific_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
def test_download_specific_platform_fails(script, data):
......@@ -262,10 +251,7 @@ def test_download_specify_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
result = script.pip(
'download', '--no-index', '--find-links', data.find_links,
......@@ -286,10 +272,9 @@ def test_download_specify_platform(script, data):
'--platform', 'macosx_10_10_x86_64',
'fake'
)
assert (
result.did_create(
Path('scratch') /
'fake-1.0-py2.py3-none-macosx_10_9_x86_64.whl'
in result.files_created
)
# OSX platform wheels are not backward-compatible.
......@@ -319,9 +304,8 @@ def test_download_specify_platform(script, data):
'--platform', 'linux_x86_64',
'fake==2'
)
assert (
result.did_create(
Path('scratch') / 'fake-2.0-py2.py3-none-linux_x86_64.whl'
in result.files_created
)
......@@ -349,10 +333,7 @@ class TestDownloadPlatformManylinuxes(object):
'--platform', platform,
'fake',
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
@pytest.mark.parametrize("wheel_abi,platform", [
("manylinux1_x86_64", "manylinux1_x86_64"),
......@@ -377,7 +358,7 @@ class TestDownloadPlatformManylinuxes(object):
'--platform', platform,
'fake',
)
assert Path('scratch') / wheel in result.files_created
result.did_create(Path('scratch') / wheel)
def test_explicit_platform_only(self, data, script):
"""
......@@ -408,10 +389,7 @@ def test_download__python_version(script, data):
'--python-version', '2',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
result = script.pip(
'download', '--no-index', '--find-links', data.find_links,
......@@ -458,10 +436,7 @@ def test_download__python_version(script, data):
'--python-version', '2',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2-none-any.whl')
result = script.pip(
'download', '--no-index', '--find-links', data.find_links,
......@@ -478,10 +453,7 @@ def test_download__python_version(script, data):
'--python-version', '3',
'fake'
)
assert (
Path('scratch') / 'fake-2.0-py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-2.0-py3-none-any.whl')
def make_wheel_with_python_requires(script, package_name, python_requires):
......@@ -555,10 +527,7 @@ def test_download_specify_abi(script, data):
'--abi', 'fake_abi',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
result = script.pip(
'download', '--no-index', '--find-links', data.find_links,
......@@ -589,9 +558,8 @@ def test_download_specify_abi(script, data):
'--abi', 'fakeabi',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-fk2-fakeabi-fake_platform.whl'
in result.files_created
)
result = script.pip(
......@@ -619,10 +587,7 @@ def test_download_specify_implementation(script, data):
'--implementation', 'fk',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-py2.py3-none-any.whl')
data.reset()
fake_wheel(data, 'fake-1.0-fk3-none-any.whl')
......@@ -634,10 +599,7 @@ def test_download_specify_implementation(script, data):
'--python-version', '3',
'fake'
)
assert (
Path('scratch') / 'fake-1.0-fk3-none-any.whl'
in result.files_created
)
result.did_create(Path('scratch') / 'fake-1.0-fk3-none-any.whl')
result = script.pip(
'download', '--no-index', '--find-links', data.find_links,
......@@ -678,14 +640,8 @@ def test_download_prefer_binary_when_tarball_higher_than_wheel(script, data):
'-f', data.packages,
'-d', '.', 'source'
)
assert (
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
in result.files_created
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
not in result.files_created
)
result.did_create(Path('scratch') / 'source-0.8-py2.py3-none-any.whl')
result.did_not_create(Path('scratch') / 'source-1.0.tar.gz')
def test_prefer_binary_tarball_higher_than_wheel_req_file(script, data):
......@@ -702,14 +658,8 @@ def test_prefer_binary_tarball_higher_than_wheel_req_file(script, data):
'-d', '.'
)
assert (
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
in result.files_created
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
not in result.files_created
)
result.did_create(Path('scratch') / 'source-0.8-py2.py3-none-any.whl')
result.did_not_create(Path('scratch') / 'source-1.0.tar.gz')
def test_download_prefer_binary_when_wheel_doesnt_satisfy_req(script, data):
......@@ -726,14 +676,8 @@ def test_download_prefer_binary_when_wheel_doesnt_satisfy_req(script, data):
'-d', '.',
'-r', script.scratch_path / 'test-req.txt'
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)
assert (
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
not in result.files_created
)
result.did_create(Path('scratch') / 'source-1.0.tar.gz')
result.did_not_create(Path('scratch') / 'source-0.8-py2.py3-none-any.whl')
def test_prefer_binary_when_wheel_doesnt_satisfy_req_req_file(script, data):
......@@ -750,14 +694,8 @@ def test_prefer_binary_when_wheel_doesnt_satisfy_req_req_file(script, data):
'-d', '.',
'-r', script.scratch_path / 'test-req.txt'
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)
assert (
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
not in result.files_created
)
result.did_create(Path('scratch') / 'source-1.0.tar.gz')
result.did_not_create(Path('scratch') / 'source-0.8-py2.py3-none-any.whl')
def test_download_prefer_binary_when_only_tarball_exists(script, data):
......@@ -768,10 +706,7 @@ def test_download_prefer_binary_when_only_tarball_exists(script, data):
'-f', data.packages,
'-d', '.', 'source'
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)
result.did_create(Path('scratch') / 'source-1.0.tar.gz')
def test_prefer_binary_when_only_tarball_exists_req_file(script, data):
......@@ -786,10 +721,7 @@ def test_prefer_binary_when_only_tarball_exists_req_file(script, data):
'-d', '.',
'-r', script.scratch_path / 'test-req.txt'
)
assert (
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)
result.did_create(Path('scratch') / 'source-1.0.tar.gz')
@pytest.fixture(scope="session")
......
......@@ -413,8 +413,9 @@ def test_new_resolver_installed(script):
)
assert "Requirement already satisfied: base~=0.1.0" in result.stdout, \
str(result)
assert script.site_packages / "base" not in result.files_updated, (
"base 0.1.0 reinstalled"
result.did_not_update(
script.site_packages / "base",
message="base 0.1.0 reinstalled"
)
......@@ -441,8 +442,9 @@ def test_new_resolver_ignore_installed(script):
"base",
)
assert satisfied_output not in result.stdout, str(result)
assert script.site_packages / "base" in result.files_updated, (
"base 0.1.0 not reinstalled"
result.did_update(
script.site_packages / "base",
message="base 0.1.0 not reinstalled"
)
......@@ -505,8 +507,9 @@ def test_new_resolver_install_different_version(script):
assert "Uninstalling base-0.1.0" in result.stdout, str(result)
assert "Successfully uninstalled base-0.1.0" in result.stdout, str(result)
assert script.site_packages / "base" in result.files_updated, (
"base not upgraded"
result.did_update(
script.site_packages / "base",
message="base not upgraded"
)
assert_installed(script, base="0.2.0")
......@@ -533,8 +536,9 @@ def test_new_resolver_force_reinstall(script):
assert "Uninstalling base-0.1.0" in result.stdout, str(result)
assert "Successfully uninstalled base-0.1.0" in result.stdout, str(result)
assert script.site_packages / "base" in result.files_updated, (
"base not reinstalled"
result.did_update(
script.site_packages / "base",
message="base not reinstalled"
)
assert_installed(script, base="0.1.0")
......@@ -738,8 +742,9 @@ def test_new_resolver_upgrade_needs_option(script):
assert "Uninstalling pkg-1.0.0" in result.stdout, str(result)
assert "Successfully uninstalled pkg-1.0.0" in result.stdout, str(result)
assert script.site_packages / "pkg" in result.files_updated, (
"pkg not upgraded"
result.did_update(
script.site_packages / "pkg",
message="pkg not upgraded"
)
assert_installed(script, pkg="2.0.0")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册