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 method to pip test result #7869

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file.
105 changes: 47 additions & 58 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,10 @@ def test_download_wheel(script, data):
'-f', data.packages,
'-d', '.', 'meta'
)
assert (
result.did_create(
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_not_create(script.site_packages / 'piptestpackage')


@pytest.mark.network
Expand All @@ -73,8 +73,10 @@ 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 +87,14 @@ 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 +107,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 +121,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 +137,10 @@ 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 +156,11 @@ 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 +171,10 @@ def test_download_vcs_link(script):
result = script.pip(
'download', '-d', '.', 'git+git://github.com/pypa/pip-test-package.git'
)
assert (
result.did_create(
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_not_create(script.site_packages / 'piptestpackage')


def test_only_binary_set_then_download_specific_platform(script, data):
Expand All @@ -184,9 +191,8 @@ def test_only_binary_set_then_download_specific_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)


Expand All @@ -204,9 +210,8 @@ def test_no_deps_set_then_download_specific_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)


Expand Down Expand Up @@ -262,9 +267,8 @@ def test_download_specify_platform(script, data):
'--platform', 'linux_x86_64',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)

result = script.pip(
Expand All @@ -286,10 +290,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 +322,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,9 +351,8 @@ def test_download_universal(self, platform, script, data):
'--platform', platform,
'fake',
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)

@pytest.mark.parametrize("wheel_abi,platform", [
Expand All @@ -377,7 +378,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,9 +409,8 @@ def test_download__python_version(script, data):
'--python-version', '2',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)

result = script.pip(
Expand Down Expand Up @@ -458,9 +458,8 @@ def test_download__python_version(script, data):
'--python-version', '2',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2-none-any.whl'
in result.files_created
)

result = script.pip(
Expand All @@ -478,9 +477,8 @@ def test_download__python_version(script, data):
'--python-version', '3',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-2.0-py3-none-any.whl'
in result.files_created
)


Expand Down Expand Up @@ -555,9 +553,8 @@ def test_download_specify_abi(script, data):
'--abi', 'fake_abi',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)

result = script.pip(
Expand Down Expand Up @@ -589,9 +586,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,9 +615,8 @@ def test_download_specify_implementation(script, data):
'--implementation', 'fk',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-py2.py3-none-any.whl'
in result.files_created
)

data.reset()
Expand All @@ -634,9 +629,8 @@ def test_download_specify_implementation(script, data):
'--python-version', '3',
'fake'
)
assert (
result.did_create(
Path('scratch') / 'fake-1.0-fk3-none-any.whl'
in result.files_created
)

result = script.pip(
Expand Down Expand Up @@ -678,13 +672,11 @@ def test_download_prefer_binary_when_tarball_higher_than_wheel(script, data):
'-f', data.packages,
'-d', '.', 'source'
)
assert (
result.did_create(
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
in result.files_created
)
assert (
result.did_not_create(
Path('scratch') / 'source-1.0.tar.gz'
not in result.files_created
)


Expand All @@ -702,13 +694,11 @@ def test_download_prefer_binary_when_wheel_doesnt_satisfy_req(script, data):
'-d', '.',
'-r', script.scratch_path / 'test-req.txt'
)
assert (
result.did_create(
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)
assert (
result.did_not_create(
Path('scratch') / 'source-0.8-py2.py3-none-any.whl'
not in result.files_created
)


Expand All @@ -720,9 +710,8 @@ def test_download_prefer_binary_when_only_tarball_exists(script, data):
'-f', data.packages,
'-d', '.', 'source'
)
assert (
result.did_create(
Path('scratch') / 'source-1.0.tar.gz'
in result.files_created
)


Expand Down