2010-02-24 11:24:55 +01:00
|
|
|
|
2010-05-02 20:11:45 +02:00
|
|
|
import textwrap, sys
|
2010-02-24 11:24:55 +01:00
|
|
|
from os.path import join
|
|
|
|
from tempfile import mkdtemp
|
2010-05-03 04:08:03 +02:00
|
|
|
from test_pip import here, reset_env, run_pip, get_env, assert_all_changes, write_file
|
2010-04-29 16:28:59 +02:00
|
|
|
from path import Path
|
2010-05-02 18:18:51 +02:00
|
|
|
import pprint
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_simple_uninstall():
|
|
|
|
"""
|
|
|
|
Test simple install and uninstall.
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-02-24 11:24:55 +01:00
|
|
|
result = run_pip('install', 'INITools==0.2', expect_error=True)
|
2010-04-15 01:33:32 +02:00
|
|
|
assert join(env.site_packages, 'initools') in result.files_created, sorted(result.files_created.keys())
|
2010-02-24 11:24:55 +01:00
|
|
|
result2 = run_pip('uninstall', 'INITools', '-y', expect_error=True)
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result2, [env.venv/'build', 'cache'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_with_scripts():
|
|
|
|
"""
|
|
|
|
Uninstall an easy_installed package with scripts.
|
|
|
|
|
2010-05-03 04:08:03 +02:00
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Uninstall an easy_installed package with scripts.
|
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
|
|
|
result = env.run('easy_install', 'PyLogo')
|
|
|
|
easy_install_pth = env.site_packages/ 'easy-install.pth'
|
2010-05-03 04:08:03 +02:00
|
|
|
pylogo = 'pylogo' if sys.platform == 'win32' else 'PyLogo'
|
|
|
|
assert(pylogo in result.files_updated[easy_install_pth].bytes)
|
2010-02-24 11:24:55 +01:00
|
|
|
result2 = run_pip('uninstall', 'pylogo', '-y', expect_error=True)
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result2, [env.venv/'build', 'cache'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_namespace_package():
|
|
|
|
"""
|
2010-02-24 11:24:55 +01:00
|
|
|
Uninstall a distribution with a namespace package without clobbering
|
2010-02-25 00:16:43 +01:00
|
|
|
the namespace and everything in it.
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-02-24 11:24:55 +01:00
|
|
|
result = run_pip('install', 'pd.requires==0.0.3', expect_error=True)
|
2010-04-15 01:33:32 +02:00
|
|
|
assert join(env.site_packages, 'pd') in result.files_created, sorted(result.files_created.keys())
|
2010-02-24 11:24:55 +01:00
|
|
|
result2 = run_pip('uninstall', 'pd.find', '-y', expect_error=True)
|
2010-04-15 01:33:32 +02:00
|
|
|
assert join(env.site_packages, 'pd') not in result2.files_deleted, sorted(result2.files_deleted.keys())
|
|
|
|
assert join(env.site_packages, 'pd', 'find') in result2.files_deleted, sorted(result2.files_deleted.keys())
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_console_scripts():
|
|
|
|
"""
|
|
|
|
Test uninstalling a package with more files (console_script entry points, extra directories).
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-02-24 11:24:55 +01:00
|
|
|
result = run_pip('install', 'virtualenv', expect_error=True)
|
2010-05-02 20:11:45 +02:00
|
|
|
assert env.bin/'virtualenv'+env.exe in result.files_created, sorted(result.files_created.keys())
|
2010-02-24 11:24:55 +01:00
|
|
|
result2 = run_pip('uninstall', 'virtualenv', '-y', expect_error=True)
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result2, [env.venv/'build', 'cache'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_easy_installed_console_scripts():
|
|
|
|
"""
|
|
|
|
Test uninstalling package with console_scripts that is easy_installed.
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
|
|
|
result = env.run('easy_install', 'virtualenv')
|
2010-05-02 20:11:45 +02:00
|
|
|
assert env.bin/'virtualenv'+env.exe in result.files_created, sorted(result.files_created.keys())
|
2010-04-28 22:55:10 +02:00
|
|
|
result2 = run_pip('uninstall', 'virtualenv', '-y')
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result2, [env.venv/'build', 'cache'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_editable_from_svn():
|
|
|
|
"""
|
|
|
|
Test uninstalling an editable installation from svn.
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-04-28 22:55:10 +02:00
|
|
|
result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev')
|
|
|
|
result.assert_installed('INITools')
|
|
|
|
result2 = run_pip('uninstall', '-y', 'initools')
|
2010-05-02 20:11:45 +02:00
|
|
|
assert (env.venv/'src'/'initools' in result2.files_after), 'oh noes, pip deleted my sources!'
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result2, [env.venv/'src', env.venv/'build'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-04-13 02:48:37 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_editable_with_source_outside_venv():
|
|
|
|
"""
|
|
|
|
Test uninstalling editable install from existing source outside the venv.
|
|
|
|
|
|
|
|
"""
|
2010-04-13 03:26:42 +02:00
|
|
|
tmpdir = join(mkdtemp(), 'virtualenv')
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-02-24 11:24:55 +01:00
|
|
|
result = env.run('hg', 'clone', 'http://bitbucket.org/ianb/virtualenv/', tmpdir)
|
|
|
|
result2 = run_pip('install', '-e', tmpdir)
|
2010-04-15 01:33:32 +02:00
|
|
|
assert (join(env.site_packages, 'virtualenv.egg-link') in result2.files_created), result2.files_created.keys()
|
2010-02-24 11:24:55 +01:00
|
|
|
result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(result, result3, [env.venv/'build'])
|
2010-04-13 02:48:37 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
def test_uninstall_from_reqs_file():
|
|
|
|
"""
|
|
|
|
Test uninstall from a requirements file.
|
|
|
|
|
|
|
|
"""
|
2010-04-15 01:33:32 +02:00
|
|
|
env = reset_env()
|
2010-02-25 00:16:43 +01:00
|
|
|
write_file('test-req.txt', textwrap.dedent("""\
|
2010-02-24 11:24:55 +01:00
|
|
|
-e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
|
|
|
|
# and something else to test out:
|
|
|
|
PyLogo<0.4
|
2010-02-25 00:16:43 +01:00
|
|
|
"""))
|
2010-02-24 11:24:55 +01:00
|
|
|
result = run_pip('install', '-r', 'test-req.txt')
|
2010-04-16 17:53:04 +02:00
|
|
|
write_file('test-req.txt', textwrap.dedent("""\
|
|
|
|
# -f, -i, and --extra-index-url should all be ignored by uninstall
|
|
|
|
-f http://www.example.com
|
|
|
|
-i http://www.example.com
|
|
|
|
--extra-index-url http://www.example.com
|
|
|
|
|
|
|
|
-e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
|
|
|
|
# and something else to test out:
|
|
|
|
PyLogo<0.4
|
|
|
|
"""))
|
2010-02-24 11:24:55 +01:00
|
|
|
result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
|
2010-05-03 04:08:03 +02:00
|
|
|
assert_all_changes(
|
|
|
|
result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])
|