Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for path lookups in test_download.py and test_new_resolver.py #8370

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
156 changes: 44 additions & 112 deletions tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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("""
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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
)


Expand Down Expand Up @@ -349,10 +333,7 @@ def test_download_universal(self, platform, script, data):
'--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"),
Expand All @@ -377,7 +358,7 @@ def test_download_compatible_manylinuxes(
'--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):
"""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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')
Expand All @@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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")
Expand Down
Loading