Skip to content

Commit

Permalink
Merge pull request #1 from socialplanning/fix-recursive-upgrades
Browse files Browse the repository at this point in the history
Add tests for recursive upgrade behaviors
  • Loading branch information
fdintino committed Jul 2, 2012
2 parents 8a38346 + 8397284 commit 43bb491
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/packages/FSPkgUsesInitools/fspkg/__init__.py
@@ -0,0 +1 @@
#
3 changes: 3 additions & 0 deletions tests/packages/FSPkgUsesInitools/setup.cfg
@@ -0,0 +1,3 @@
[egg_info]
tag_build = dev
tag_svn_revision = true
25 changes: 25 additions & 0 deletions tests/packages/FSPkgUsesInitools/setup.py
@@ -0,0 +1,25 @@
from setuptools import setup, find_packages

version = '0.1'

setup(name='FSPkgUsesInitools',
version=version,
description="File system test package",
long_description="""\
File system test package""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='pip tests',
author='pip',
author_email='pip@openplans.org',
url='http://pip.openplans.org',
license='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
"INItools",
],
entry_points="""
# -*- Entry points: -*-
""",
)
@@ -0,0 +1 @@
#
@@ -0,0 +1,3 @@
[egg_info]
tag_build = dev
tag_svn_revision = true
25 changes: 25 additions & 0 deletions tests/packages/FSPkgUsesNewishInitools/FSPkgUsesInitools/setup.py
@@ -0,0 +1,25 @@
from setuptools import setup, find_packages

version = '0.1'

setup(name='FSPkgUsesInitools',
version=version,
description="File system test package",
long_description="""\
File system test package""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='pip tests',
author='pip',
author_email='pip@openplans.org',
url='http://pip.openplans.org',
license='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
"INItools",
],
entry_points="""
# -*- Entry points: -*-
""",
)
1 change: 1 addition & 0 deletions tests/packages/FSPkgUsesNewishInitools/fspkg/__init__.py
@@ -0,0 +1 @@
#
3 changes: 3 additions & 0 deletions tests/packages/FSPkgUsesNewishInitools/setup.cfg
@@ -0,0 +1,3 @@
[egg_info]
tag_build = dev
tag_svn_revision = true
25 changes: 25 additions & 0 deletions tests/packages/FSPkgUsesNewishInitools/setup.py
@@ -0,0 +1,25 @@
from setuptools import setup, find_packages

version = '0.1'

setup(name='FSPkgUsesNewishInitools',
version=version,
description="File system test package",
long_description="""\
File system test package""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='pip tests',
author='pip',
author_email='pip@openplans.org',
url='http://pip.openplans.org',
license='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
"INItools>=0.3",
],
entry_points="""
# -*- Entry points: -*-
""",
)
76 changes: 75 additions & 1 deletion tests/test_upgrade.py
@@ -1,5 +1,5 @@
import textwrap
from os.path import join
from os.path import abspath, join
from nose.tools import nottest
from tests.test_pip import (here, reset_env, run_pip, assert_all_changes,
write_file, pyversion, _create_test_package,
Expand Down Expand Up @@ -56,6 +56,79 @@ def test_upgrade_with_newest_already_installed():
assert 'already up-to-date' in result.stdout


def test_upgrade_without_unneeded_recursive_upgrades():
"""
When upgrading a single package, that package's own dependencies should not be
upgraded unnecessarily if the user doesn't explicitly ask for them to be upgraded.
"""
env = reset_env()
run_pip('install', 'INITools==0.2')

to_install = abspath(join(here, 'packages', 'FSPkgUsesInitools'))
result = run_pip('install', to_install)

result = run_pip('install', '--upgrade', to_install)

assert env.site_packages/ 'initools'/'__init__.py' not in result.files_updated, 'pip install --upgrade upgraded recursive dependency INITools when it should not have'


def test_upgrade_with_needed_recursive_upgrades():
"""
When upgrading a single package A, that package's own dependencies should be
upgraded if the installed versions no longer satisfy A's requirements, even if
the user doesn't explicitly ask for them to be upgraded,
"""
env = reset_env()
to_install = abspath(join(here, 'packages', 'FSPkgUsesNewishInitools'))
result = run_pip('install', to_install)
run_pip('install', 'INITools==0.2')

result = run_pip('install', '--upgrade', to_install)

assert env.site_packages/ 'initools'/'configparser.py' in result.files_created, 'pip install --upgrade failed to upgrade recursive dependency INITools when it should have'


def test_upgrade_with_unneeded_recursive_upgrades_explicitly_requested():
"""
When upgrading a single package A with --upgrade-recursive, all of A's
dependencies should be upgraded as well, even if the installed versions
already satisfy A's requirements.
"""
env = reset_env()
run_pip('install', 'INITools==0.2')

to_install = abspath(join(here, 'packages', 'FSPkgUsesInitools'))
result = run_pip('install', to_install)

result = run_pip('install', '--upgrade-recursive', to_install)

assert env.site_packages/ 'initools'/'__init__.py' in result.files_updated, 'pip install --upgrade failed to upgrade recursive dependency INITools when it was asked to'


def test_upgrade_reqs_file_without_unneeded_recursive_upgrades():
"""
When running non-recursive --upgrade against a requirements file, every package
explicitly listed in the requirements file should be upgraded; but any recursive
dependencies should not be upgraded.
"""
env = reset_env()
run_pip('install', 'INITools==0.2')
run_pip('install', 'PyLogo==0.1')

to_install = abspath(join(here, 'packages', 'FSPkgUsesInitools'))
result = run_pip('install', to_install)

write_file('test-req.txt', textwrap.dedent("""\
%(FSPkgUsesInitools)s
PyLogo
""" % {'FSPkgUsesInitools': to_install}))

result = run_pip('install', '--upgrade', '-r', env.scratch_path/ 'test-req.txt')

assert env.site_packages/ 'initools'/'__init__.py' not in result.files_updated, 'pip install --upgrade upgraded recursive dependency INITools when it should not have'
assert env.site_packages/ 'pylogo'/'__init__.py' in result.files_updated, 'pip install --upgrade failed to upgrade explicit dependency PyLogo when it should have'


def test_upgrade_force_reinstall_newest():
"""
Force reinstallation of a package even if it is already at its newest
Expand Down Expand Up @@ -212,3 +285,4 @@ def test_upgrade_vcs_req_with_dist_found():
run_pip("install", req)
result = run_pip("install", "-U", req)
assert not "pypi.python.org" in result.stdout, result.stdout

0 comments on commit 43bb491

Please sign in to comment.