Skip to content

Commit

Permalink
test_install_package_with_target: No network
Browse files Browse the repository at this point in the history
and also fix intermittent failures reported in
pypa#2580
  • Loading branch information
msabramo committed Mar 23, 2015
1 parent 3b14a4f commit 291bb12
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
Binary file added tests/data/packages/singlemodule-0.0.0.tar.gz
Binary file not shown.
Binary file added tests/data/packages/singlemodule-0.0.1.tar.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/data/src/singlemodule/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
universal=1
9 changes: 9 additions & 0 deletions tests/data/src/singlemodule/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from setuptools import setup


setup(
name="singlemodule",
version='0.0.1',
description="A sample Python project with a single module",
py_modules=['singlemodule'],
)
3 changes: 3 additions & 0 deletions tests/data/src/singlemodule/singlemodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def main():
"""Entry point for the application script"""
print("Call your main application code here")
31 changes: 14 additions & 17 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,43 +531,40 @@ def test_install_package_which_contains_dev_in_name(script):
assert egg_info_folder in result.files_created, str(result)


@pytest.mark.network
def test_install_package_with_target(script):
"""
Test installing a package using pip install --target
"""
target_dir = script.scratch_path / 'target'
result = script.pip('install', '-t', target_dir, "initools==0.1")
assert Path('scratch') / 'target' / 'initools' in result.files_created, (
result = script.pip_install_local('-t', target_dir, "simple==1.0")
assert Path('scratch') / 'target' / 'simple' in result.files_created, (
str(result)
)

# Test repeated call without --upgrade, no files should have changed
result = script.pip('install', '-t', target_dir, "initools==0.1")
assert not Path('scratch') / 'target' / 'initools' in result.files_updated
result = script.pip_install_local('-t', target_dir, "simple==1.0")
assert not Path('scratch') / 'target' / 'simple' in result.files_updated

# Test upgrade call, check that new version is installed
result = script.pip('install', '--upgrade', '-t',
target_dir, "initools==0.2")
assert Path('scratch') / 'target' / 'initools' in result.files_updated, (
result = script.pip_install_local('--upgrade', '-t',
target_dir, "simple==2.0")
assert Path('scratch') / 'target' / 'simple' in result.files_updated, (
str(result)
)
egg_folder = (
Path('scratch') / 'target' / 'INITools-0.2-py%s.egg-info' % pyversion)
Path('scratch') / 'target' / 'simple-2.0-py%s.egg-info' % pyversion)
assert egg_folder in result.files_created, (
str(result)
)

# Test install and upgrade of single-module package
result = script.pip('install', '-t', target_dir, 'six')
assert Path('scratch') / 'target' / 'six.py' in result.files_created, (
str(result)
)
result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.0')
singlemodule_py = Path('scratch') / 'target' / 'singlemodule.py'
assert singlemodule_py in result.files_created, str(result)

result = script.pip('install', '-t', target_dir, '--upgrade', 'six')
assert Path('scratch') / 'target' / 'six.py' in result.files_updated, (
str(result)
)
result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.1',
'--upgrade')
assert singlemodule_py in result.files_updated, str(result)


def test_install_package_with_root(script, data):
Expand Down

0 comments on commit 291bb12

Please sign in to comment.