summaryrefslogtreecommitdiff
path: root/tests/test_upgrade.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_upgrade.py')
-rw-r--r--tests/test_upgrade.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py
index 4d2145bb8..c6b8d686a 100644
--- a/tests/test_upgrade.py
+++ b/tests/test_upgrade.py
@@ -41,6 +41,34 @@ def test_upgrade_if_requested():
assert env.site_packages/'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created
+def test_upgrade_with_newest_already_installed():
+ """
+ If the newest version of a package is already installed, the package should
+ not be reinstalled and the user should be informed.
+ """
+
+ env = reset_env()
+ run_pip('install', 'INITools')
+ result = run_pip('install', '--upgrade', 'INITools')
+ assert not result.files_created, 'pip install --upgrade INITools upgraded when it should not have'
+ assert 'already up-to-date' in result.stdout
+
+
+def test_upgrade_force_reinstall_newest():
+ """
+ Force reinstallation of a package even if it is already at its newest
+ version if --force-reinstall is supplied.
+ """
+
+ env = reset_env()
+ result = run_pip('install', 'INITools')
+ assert env.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
+ result2 = run_pip('install', '--upgrade', '--force-reinstall', 'INITools')
+ assert result2.files_updated, 'upgrade to INITools 0.3 failed'
+ result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
+ assert_all_changes(result, result3, [env.venv/'build', 'cache'])
+
+
def test_uninstall_before_upgrade():
"""
Automatic uninstall-before-upgrade.
@@ -54,6 +82,7 @@ def test_uninstall_before_upgrade():
result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
assert_all_changes(result, result3, [env.venv/'build', 'cache'])
+
def test_uninstall_before_upgrade_from_url():
"""
Automatic uninstall-before-upgrade from URL.
@@ -67,6 +96,7 @@ def test_uninstall_before_upgrade_from_url():
result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
assert_all_changes(result, result3, [env.venv/'build', 'cache'])
+
def test_upgrade_to_same_version_from_url():
"""
When installing from a URL the same version that is already installed, no
@@ -81,6 +111,7 @@ def test_upgrade_to_same_version_from_url():
result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
assert_all_changes(result, result3, [env.venv/'build', 'cache'])
+
def test_upgrade_from_reqs_file():
"""
Upgrade from a requirements file.
@@ -134,6 +165,7 @@ def test_editable_git_upgrade():
version2 = env.run('version_pkg')
assert 'some different version' in version2.stdout
+
def test_should_not_install_always_from_cache():
"""
If there is an old cached package, pip should download the newer version
@@ -146,6 +178,7 @@ def test_should_not_install_always_from_cache():
assert env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion not in result.files_created
assert env.site_packages/'INITools-0.1-py%s.egg-info' % pyversion in result.files_created
+
def test_install_with_ignoreinstalled_requested():
"""
It installs package if ignore installed is set.
@@ -153,6 +186,7 @@ def test_install_with_ignoreinstalled_requested():
"""
env = reset_env()
run_pip('install', 'INITools==0.1', expect_error=True)
- result = run_pip('install', '-I' , 'INITools', expect_error=True)
+ result = run_pip('install', '-I', 'INITools', expect_error=True)
assert result.files_created, 'pip install -I did not install'
assert env.site_packages/'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created
+