mirror of https://github.com/pypa/pip
fix test names, remove old doctest files
This commit is contained in:
parent
717a0c2065
commit
4060b810c5
|
@ -2,19 +2,21 @@
|
|||
from os.path import abspath, join, dirname, pardir
|
||||
from test_pip import here, reset_env, run_pip, pyversion, lib_py
|
||||
|
||||
def test_0():
|
||||
'''
|
||||
Check we are running proper version of pip in run_pip::
|
||||
'''
|
||||
def test_correct_pip_version():
|
||||
"""
|
||||
Check we are running proper version of pip in run_pip.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
base = abspath(join(dirname(__file__), pardir))
|
||||
result = run_pip('--version')
|
||||
assert base in result.stdout, result.stdout
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
First a test of the distutils-configuration-setting command (which is distinct from other commands)::
|
||||
'''
|
||||
def test_distutils_configuration_setting():
|
||||
"""
|
||||
Test the distutils-configuration-setting command (which is distinct from other commands).
|
||||
|
||||
"""
|
||||
#print run_pip('-vv', '--distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/', expect_error=True)
|
||||
#Script result: python ../../poacheggs.py -E .../poacheggs-tests/test-scratch -vv --distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/
|
||||
#-- stdout: --------------------
|
||||
|
@ -25,29 +27,32 @@ def test_1():
|
|||
#-- updated: -------------------
|
||||
# lib/python2.4/distutils/distutils.cfg (346 bytes)
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Next, a simple test::
|
||||
'''
|
||||
def test_install_from_pypi():
|
||||
"""
|
||||
Test installing a package from PyPI.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-vvv', 'INITools==0.2', expect_error=True)
|
||||
assert (lib_py + 'site-packages/INITools-0.2-py%s.egg-info' % pyversion) in result.files_created, str(result) #sorted(result.files_created.keys())
|
||||
assert (lib_py + 'site-packages/INITools-0.2-py%s.egg-info' % pyversion) in result.files_created, str(result)
|
||||
assert (lib_py + 'site-packages/initools') in result.files_created, sorted(result.files_created.keys())
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
Let's try that again, editable::
|
||||
'''
|
||||
def test_editable_install():
|
||||
"""
|
||||
Test editable installation.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'INITools==0.2', expect_error=True)
|
||||
assert "--editable=INITools==0.2 should be formatted with svn+URL" in result.stdout
|
||||
assert len(result.files_created) == 1, result.files_created
|
||||
assert not result.files_updated, result.files_updated
|
||||
|
||||
def test_4():
|
||||
'''
|
||||
Now, checking out from svn::
|
||||
'''
|
||||
def test_install_editable_from_svn():
|
||||
"""
|
||||
Test checking out from svn.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
|
||||
egg_link = result.files_created[lib_py + 'site-packages/INITools.egg-link']
|
||||
|
@ -58,18 +63,20 @@ def test_4():
|
|||
assert 'src/initools/.svn' in result.files_created
|
||||
|
||||
|
||||
def test_5():
|
||||
'''
|
||||
Using package==dev::
|
||||
'''
|
||||
def test_install_dev_version_from_pypi():
|
||||
"""
|
||||
Test using package==dev.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==dev', expect_error=True)
|
||||
assert (lib_py + 'site-packages/initools') in result.files_created, str(result.stdout)
|
||||
|
||||
def test_6():
|
||||
'''
|
||||
Cloning from Git::
|
||||
'''
|
||||
def test_install_editable_from_git():
|
||||
"""
|
||||
Test cloning from Git.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'git://github.com/jezdez/django-feedutil.git#egg=django-feedutil', expect_error=True)
|
||||
egg_link = result.files_created[lib_py + 'site-packages/django-feedutil.egg-link']
|
||||
|
@ -79,10 +86,11 @@ def test_6():
|
|||
assert 'src/django-feedutil' in result.files_created
|
||||
assert 'src/django-feedutil/.git' in result.files_created
|
||||
|
||||
def test_7():
|
||||
'''
|
||||
Cloning from Mercurial::
|
||||
'''
|
||||
def test_install_editable_from_hg():
|
||||
"""
|
||||
Test cloning from Mercurial.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'hg+http://bitbucket.org/ubernostrum/django-registration/#egg=django-registration', expect_error=True)
|
||||
egg_link = result.files_created[lib_py + 'site-packages/django-registration.egg-link']
|
||||
|
@ -92,18 +100,20 @@ def test_7():
|
|||
assert 'src/django-registration' in result.files_created
|
||||
assert 'src/django-registration/.hg' in result.files_created
|
||||
|
||||
def test_8():
|
||||
'''
|
||||
Presence or absence of final slash is also normalized::
|
||||
'''
|
||||
def test_vcs_url_final_slash_normalization():
|
||||
"""
|
||||
Test that presence or absence of final slash in VCS URL is normalized.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'hg+http://bitbucket.org/ubernostrum/django-registration#egg=django-registration', expect_error=True)
|
||||
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
||||
def test_9():
|
||||
'''
|
||||
Checking out from Bazaar::
|
||||
'''
|
||||
def test_install_editable_from_bazaar():
|
||||
"""
|
||||
Test checking out from Bazaar.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/@174#egg=django-wikiapp', expect_error=True)
|
||||
egg_link = result.files_created[lib_py + 'site-packages/django-wikiapp.egg-link']
|
||||
|
@ -113,10 +123,11 @@ def test_9():
|
|||
assert 'src/django-wikiapp' in result.files_created
|
||||
assert 'src/django-wikiapp/.bzr' in result.files_created
|
||||
|
||||
def test_10():
|
||||
'''
|
||||
Urlquoted characters are normalized for repo URL comparison::
|
||||
'''
|
||||
def test_vcs_url_urlquote_normalization():
|
||||
"""
|
||||
Test that urlquoted characters are normalized for repo URL comparison.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/~django-wikiapp/django-wikiapp/release-0.1#egg=django-wikiapp', expect_error=True)
|
||||
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from __main__ import here, reset_env, run_pip, pyversion, lib_py
|
||||
>>> reset_env()
|
||||
|
||||
First a test of the distutils-configuration-setting command (which is distinct from other commands)::
|
||||
|
||||
#>>> print run_pip('-vv', '--distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/', expect_error=True)
|
||||
#Script result: python ../../poacheggs.py -E .../poacheggs-tests/test-scratch -vv --distutils-cfg=easy_install:index_url:http://download.zope.org/ppix/
|
||||
#-- stdout: --------------------
|
||||
#Distutils config .../poacheggs-tests/test-scratch/lib/python.../distutils/distutils.cfg is writable
|
||||
#Replaced setting index_url
|
||||
#Updated .../poacheggs-tests/test-scratch/lib/python.../distutils/distutils.cfg
|
||||
#<BLANKLINE>
|
||||
#-- updated: -------------------
|
||||
# lib/python2.4/distutils/distutils.cfg (346 bytes)
|
||||
|
||||
Next, a simple test::
|
||||
|
||||
>>> result = run_pip('install', '-vvv', 'INITools==0.2', expect_error=True)
|
||||
>>> assert (lib_py + 'site-packages/INITools-0.2-py%s.egg-info' % pyversion) in result.files_created, str(result) #sorted(result.files_created.keys())
|
||||
>>> assert (lib_py + 'site-packages/initools') in result.files_created, sorted(result.files_created.keys())
|
||||
|
||||
Let's try that again, editable::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'INITools==0.2', expect_error=True)
|
||||
>>> assert "--editable=INITools==0.2 should be formatted with svn+URL" in result.stdout
|
||||
>>> assert len(result.files_created) == 1, result.files_created
|
||||
>>> assert not result.files_updated, result.files_updated
|
||||
|
||||
Now, checking out from svn::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
|
||||
>>> egg_link = result.files_created[lib_py + 'site-packages/INITools.egg-link']
|
||||
>>> # FIXME: I don't understand why there's a trailing . here:
|
||||
>>> egg_link.bytes
|
||||
'.../test-scratch/src/initools\n.'
|
||||
>>> assert (lib_py + 'site-packages/easy-install.pth') in result.files_updated
|
||||
>>> assert 'src/initools' in result.files_created
|
||||
>>> assert 'src/initools/.svn' in result.files_created
|
||||
|
||||
|
||||
Using package==dev::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==dev', expect_error=True)
|
||||
>>> assert (lib_py + 'site-packages/initools') in result.files_created, str(result.stdout)
|
||||
|
||||
Cloning from Git::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'git://github.com/jezdez/django-feedutil.git#egg=django-feedutil', expect_error=True)
|
||||
>>> egg_link = result.files_created[lib_py + 'site-packages/django-feedutil.egg-link']
|
||||
>>> # FIXME: I don't understand why there's a trailing . here:
|
||||
>>> egg_link.bytes
|
||||
'.../test-scratch/src/django-feedutil\n.'
|
||||
>>> assert (lib_py + 'site-packages/easy-install.pth') in result.files_updated
|
||||
>>> assert 'src/django-feedutil' in result.files_created
|
||||
>>> assert 'src/django-feedutil/.git' in result.files_created
|
||||
|
||||
Cloning from Mercurial::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'hg+http://bitbucket.org/ubernostrum/django-registration/#egg=django-registration', expect_error=True)
|
||||
>>> egg_link = result.files_created[lib_py + 'site-packages/django-registration.egg-link']
|
||||
>>> # FIXME: I don't understand why there's a trailing . here:
|
||||
>>> egg_link.bytes
|
||||
'.../test-scratch/src/django-registration\n.'
|
||||
>>> assert (lib_py + 'site-packages/easy-install.pth') in result.files_updated
|
||||
>>> assert 'src/django-registration' in result.files_created
|
||||
>>> assert 'src/django-registration/.hg' in result.files_created
|
||||
|
||||
Presence or absence of final slash is also normalized::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'hg+http://bitbucket.org/ubernostrum/django-registration#egg=django-registration', expect_error=True)
|
||||
>>> assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
||||
Checking out from Bazaar::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/@174#egg=django-wikiapp', expect_error=True)
|
||||
>>> egg_link = result.files_created[lib_py + 'site-packages/django-wikiapp.egg-link']
|
||||
>>> # FIXME: I don't understand why there's a trailing . here:
|
||||
>>> egg_link.bytes
|
||||
'.../test-scratch/src/django-wikiapp\n.'
|
||||
>>> assert (lib_py + 'site-packages/easy-install.pth') in result.files_updated
|
||||
>>> assert 'src/django-wikiapp' in result.files_created
|
||||
>>> assert 'src/django-wikiapp/.bzr' in result.files_created
|
||||
|
||||
Urlquoted characters are normalized for repo URL comparison::
|
||||
|
||||
>>> result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/~django-wikiapp/django-wikiapp/release-0.1#egg=django-wikiapp', expect_error=True)
|
||||
>>> assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
|
@ -5,12 +5,13 @@ from os.path import abspath, join, dirname, pardir
|
|||
from test_pip import here, reset_env, run_pip, pyversion, lib_py
|
||||
from test_pip import write_file
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
Test making a bundle. We'll grab one package from the filesystem (the
|
||||
FSPkg dummy package), one from vcs (initools) and one from an index
|
||||
(pip itself)::
|
||||
'''
|
||||
def test_create_bundle():
|
||||
"""
|
||||
Test making a bundle. We'll grab one package from the filesystem
|
||||
(the FSPkg dummy package), one from vcs (initools) and one from an
|
||||
index (pip itself).
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
fspkg = 'file://%s/FSPkg' %join(here, 'packages')
|
||||
dummy = run_pip('install', '-e', fspkg)
|
||||
|
@ -26,4 +27,3 @@ def test_1():
|
|||
assert 'src/FSPkg/' in files
|
||||
assert 'src/initools/' in files
|
||||
assert 'build/pip/' in files
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from __main__ import here, reset_env, run_pip, pyversion, lib_py
|
||||
>>> from __main__ import write_file
|
||||
>>> from os.path import join
|
||||
>>> import zipfile
|
||||
>>> reset_env()
|
||||
|
||||
Test making a bundle. We'll grab one package from the filesystem (the
|
||||
FSPkg dummy package), one from vcs (initools) and one from an index
|
||||
(pip itself)::
|
||||
|
||||
>>> fspkg = 'file://%s/FSPkg' %join(here, 'packages')
|
||||
>>> dummy = run_pip('install', '-e', fspkg)
|
||||
>>> pkg_lines = '''-e %s\n''' %fspkg
|
||||
>>> pkg_lines = pkg_lines + """
|
||||
... -e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
|
||||
... pip"""
|
||||
>>> write_file('bundle-req.txt', pkg_lines)
|
||||
>>> result = run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
|
||||
>>> bundle = result.files_after.get('test.pybundle', None)
|
||||
>>> bundle is not None
|
||||
True
|
||||
|
||||
>>> files = zipfile.ZipFile(bundle.full).namelist()
|
||||
>>> 'src/FSPkg/' in files
|
||||
True
|
||||
|
||||
>>> 'src/initools/' in files
|
||||
True
|
||||
|
||||
>>> 'build/pip/' in files
|
||||
True
|
||||
|
||||
Cleanup::
|
||||
|
||||
>>> reset_env()
|
|
@ -4,10 +4,11 @@ import textwrap
|
|||
from test_pip import here, reset_env, run_pip, clear_environ, write_file
|
||||
import os
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
def test_options_from_env_vars():
|
||||
"""
|
||||
Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)
|
||||
'''
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_NO_INDEX'] = '1'
|
||||
reset_env(environ)
|
||||
|
@ -15,10 +16,11 @@ def test_1():
|
|||
assert "Ignoring indexes:" in result.stdout, str(result)
|
||||
assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Test if command line options override environmental variables
|
||||
'''
|
||||
def test_command_line_options_override_env_vars():
|
||||
"""
|
||||
Test that command line options override environmental variables.
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_INDEX_URL'] = 'http://pypi.appspot.com/'
|
||||
reset_env(environ)
|
||||
|
@ -29,10 +31,11 @@ def test_2():
|
|||
assert "http://pypi.appspot.com/INITools" not in result.stdout
|
||||
assert "Getting page http://download.zope.org/ppix" in result.stdout
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
Test command line flags that append to defaults set by environmental variables
|
||||
'''
|
||||
def test_command_line_append_flags():
|
||||
"""
|
||||
Test command line flags that append to defaults set by environmental variables.
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
|
||||
reset_env(environ)
|
||||
|
@ -43,27 +46,29 @@ def test_3():
|
|||
assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
|
||||
assert "Analyzing links from page http://example.com" in result.stdout
|
||||
|
||||
def test_4():
|
||||
'''
|
||||
Test config files (global, overriding a global config with a local, overriding all with a command line flag)
|
||||
'''
|
||||
def test_config_file_override_stack():
|
||||
"""
|
||||
Test config files (global, overriding a global config with a
|
||||
local, overriding all with a command line flag).
|
||||
|
||||
"""
|
||||
f, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
|
||||
reset_env(environ)
|
||||
write_file(config_file, textwrap.dedent('''\
|
||||
write_file(config_file, textwrap.dedent("""\
|
||||
[global]
|
||||
index-url = http://download.zope.org/ppix
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
|
||||
reset_env(environ)
|
||||
write_file(config_file, textwrap.dedent('''\
|
||||
write_file(config_file, textwrap.dedent("""\
|
||||
[global]
|
||||
index-url = http://download.zope.org/ppix
|
||||
[install]
|
||||
index-url = http://pypi.appspot.com/
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
|
||||
result = run_pip('install', '-vvv', '--index-url', 'http://pypi.python.org/simple', 'INITools', expect_error=True)
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from __main__ import here, reset_env, run_pip, clear_environ, write_file
|
||||
>>> import os
|
||||
|
||||
Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)
|
||||
|
||||
>>> environ = clear_environ(os.environ.copy())
|
||||
>>> environ['PIP_NO_INDEX'] = '1'
|
||||
>>> reset_env(environ)
|
||||
>>> result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
>>> assert "Ignoring indexes:" in result.stdout, str(result)
|
||||
>>> assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
|
||||
|
||||
Test if command line options override environmental variables
|
||||
|
||||
>>> environ = clear_environ(os.environ.copy())
|
||||
>>> environ['PIP_INDEX_URL'] = 'http://pypi.appspot.com/'
|
||||
>>> reset_env(environ)
|
||||
>>> result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
>>> assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
|
||||
>>> reset_env(environ)
|
||||
>>> result = run_pip('install', '-vvv', '--index-url', 'http://download.zope.org/ppix', 'INITools', expect_error=True)
|
||||
>>> assert "http://pypi.appspot.com/INITools" not in result.stdout
|
||||
>>> assert "Getting page http://download.zope.org/ppix" in result.stdout
|
||||
|
||||
Test command line flags that append to defaults set by environmental variables
|
||||
|
||||
>>> environ = clear_environ(os.environ.copy())
|
||||
>>> environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
|
||||
>>> reset_env(environ)
|
||||
>>> result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
>>> assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
|
||||
>>> reset_env(environ)
|
||||
>>> result = run_pip('install', '-vvv', '--find-links', 'http://example.com', 'INITools', expect_error=True)
|
||||
>>> assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
|
||||
>>> assert "Analyzing links from page http://example.com" in result.stdout
|
||||
|
||||
Test config files (global, overriding a global config with a local, overriding all with a command line flag)
|
||||
|
||||
>>> import tempfile
|
||||
>>> f, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
|
||||
>>> environ = clear_environ(os.environ.copy())
|
||||
>>> environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
|
||||
>>> reset_env(environ)
|
||||
>>> write_file(config_file, '''\
|
||||
... [global]
|
||||
... index-url = http://download.zope.org/ppix
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
>>> assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
|
||||
>>> reset_env(environ)
|
||||
>>> write_file(config_file, '''\
|
||||
... [global]
|
||||
... index-url = http://download.zope.org/ppix
|
||||
... [install]
|
||||
... index-url = http://pypi.appspot.com/
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
>>> assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
|
||||
>>> result = run_pip('install', '-vvv', '--index-url', 'http://pypi.python.org/simple', 'INITools', expect_error=True)
|
||||
>>> assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
|
||||
>>> assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
|
||||
>>> assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
|
|
@ -4,29 +4,33 @@ import textwrap
|
|||
from doctest import OutputChecker, ELLIPSIS
|
||||
from test_pip import base_path, reset_env, run_pip, pyversion, lib_py, write_file, get_env
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
def test_freeze():
|
||||
"""
|
||||
Some tests of freeze, first we have to install some stuff. Note that
|
||||
the test is a little crude at the end because Python 2.5+ adds egg
|
||||
info to the standard library, so stuff like wsgiref will show up in
|
||||
the freezing. (Probably that should be accounted for in pip, but
|
||||
currently it is not). ::
|
||||
'''
|
||||
currently it is not).
|
||||
|
||||
TODO: refactor this test into multiple tests? (and maybe different
|
||||
test style instead of using doctest output checker)
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
checker = OutputChecker()
|
||||
write_file('initools-req.txt', textwrap.dedent('''\
|
||||
write_file('initools-req.txt', textwrap.dedent("""\
|
||||
INITools==0.2
|
||||
# and something else to test out:
|
||||
simplejson<=1.7.4
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-r', 'initools-req.txt')
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
# Now lets try it with an svn checkout::
|
||||
|
@ -35,18 +39,18 @@ def test_1():
|
|||
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
cwd=os.path.join(env.base_path, 'initools-trunk'))
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk@3472#egg=INITools-0.2.1dev_r3472-py2...-dev_r3472
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
# Now, straight from trunk (but not editable/setup.py develop)::
|
||||
result = env.run(os.path.join(env.base_path, 'bin/easy_install'), 'http://svn.colorstudy.com/INITools/trunk')
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stderr: --------------------
|
||||
Warning: cannot find svn location for INITools==...dev-r...
|
||||
|
@ -55,25 +59,26 @@ def test_1():
|
|||
## FIXME: could not find svn URL in dependency_links for this package:
|
||||
INITools==...dev-r...
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
# Bah, that's no good! Let's give it a hint::
|
||||
result = run_pip('freeze', '-f', 'http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
|
||||
-- stdout: --------------------
|
||||
-f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
|
||||
# Installing as editable to satisfy requirement INITools==...dev-r...:
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk@...#egg=INITools-...dev_r...
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
What about a Git clone?::
|
||||
'''
|
||||
def test_freeze_git_clone():
|
||||
"""
|
||||
Test freezing a Git clone.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
checker = OutputChecker()
|
||||
|
@ -83,26 +88,27 @@ def test_2():
|
|||
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
cwd=os.path.join(env.base_path, 'django-pagination'))
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
result = run_pip('freeze', '-f', 'git://github.com/jezdez/django-pagination.git#egg=django_pagination', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f git://github.com/jezdez/django-pagination.git#egg=django_pagination
|
||||
-- stdout: --------------------
|
||||
-f git://github.com/jezdez/django-pagination.git#egg=django_pagination
|
||||
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...-dev
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
Now what about Mercurial::
|
||||
'''
|
||||
def test_freeze_mercurial_clone():
|
||||
"""
|
||||
Test freezing a Mercurial clone.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
checker = OutputChecker()
|
||||
|
@ -110,26 +116,27 @@ def test_3():
|
|||
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
cwd=os.path.join(env.base_path, 'django-dbtemplates'))
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
result = run_pip('freeze', '-f', 'hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
|
||||
-- stdout: --------------------
|
||||
-f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
|
||||
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
def test_4():
|
||||
'''
|
||||
Heck, now look in the Bazaar::
|
||||
'''
|
||||
def test_freeze_bazaar_clone():
|
||||
"""
|
||||
Test freezing a Bazaar clone.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
checker = OutputChecker()
|
||||
|
@ -137,43 +144,44 @@ def test_4():
|
|||
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
cwd=os.path.join(env.base_path, 'django-wikiapp'))
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
result = run_pip('freeze', '-f', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
|
||||
-- stdout: --------------------
|
||||
-f bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
|
||||
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
|
||||
...''')
|
||||
...""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
def test_5():
|
||||
'''
|
||||
Test that wsgiref (from global site-packages) is reported normally, but not with --local::
|
||||
'''
|
||||
def test_freeze_with_local_option():
|
||||
"""
|
||||
Test that wsgiref (from global site-packages) is reported normally, but not with --local.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
checker = OutputChecker()
|
||||
result = run_pip('install', 'initools==0.2')
|
||||
result = run_pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
wsgiref==...
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
result = run_pip('freeze', '--local', expect_stderr=True)
|
||||
expected = textwrap.dedent('''\
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze --local
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
<BLANKLINE>''')
|
||||
<BLANKLINE>""")
|
||||
assert checker.check_output(expected, str(result), ELLIPSIS), result
|
||||
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> import os
|
||||
>>> from __main__ import base_path, reset_env, run_pip, pyversion, lib_py, write_file, get_env
|
||||
|
||||
Some tests of freeze, first we have to install some stuff. Note that
|
||||
the test is a little crude at the end because Python 2.5+ adds egg
|
||||
info to the standard library, so stuff like wsgiref will show up in
|
||||
the freezing. (Probably that should be accounted for in pip, but
|
||||
currently it is not). ::
|
||||
|
||||
>>> reset_env()
|
||||
>>> write_file('initools-req.txt', '''\
|
||||
... INITools==0.2
|
||||
... # and something else to test out:
|
||||
... simplejson<=1.7.4
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-r', 'initools-req.txt')
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>
|
||||
|
||||
Now lets try it with an svn checkout::
|
||||
|
||||
>>> env = get_env()
|
||||
>>> result = env.run('svn', 'co', '-r3472', 'http://svn.colorstudy.com/INITools/trunk', 'initools-trunk')
|
||||
>>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
... cwd=os.path.join(env.base_path, 'initools-trunk'))
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk@3472#egg=INITools-0.2.1dev_r3472-py2...-dev_r3472
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>
|
||||
|
||||
Now, straight from trunk (but not editable/setup.py develop)::
|
||||
|
||||
>>> result = env.run(os.path.join(env.base_path, 'bin/easy_install'), 'http://svn.colorstudy.com/INITools/trunk')
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stderr: --------------------
|
||||
Warning: cannot find svn location for INITools==...dev-r...
|
||||
<BLANKLINE>
|
||||
-- stdout: --------------------
|
||||
## FIXME: could not find svn URL in dependency_links for this package:
|
||||
INITools==...dev-r...
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>
|
||||
|
||||
Bah, that's no good! Let's give it a hint::
|
||||
|
||||
>>> result = run_pip('freeze', '-f', 'http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
|
||||
-- stdout: --------------------
|
||||
-f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
|
||||
# Installing as editable to satisfy requirement INITools==...dev-r...:
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk@...#egg=INITools-...dev_r...
|
||||
simplejson==1.7.4...
|
||||
<BLANKLINE>
|
||||
|
||||
What about a Git clone?::
|
||||
|
||||
>>> reset_env()
|
||||
>>> env = get_env()
|
||||
>>> result = env.run('git', 'clone', 'git://github.com/jezdez/django-pagination.git', 'django-pagination')
|
||||
>>> result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8',
|
||||
... cwd=os.path.join(env.base_path, 'django-pagination'), expect_stderr=True)
|
||||
>>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
... cwd=os.path.join(env.base_path, 'django-pagination'))
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...
|
||||
...
|
||||
|
||||
>>> result = run_pip('freeze', '-f', 'git://github.com/jezdez/django-pagination.git#egg=django_pagination', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f git://github.com/jezdez/django-pagination.git#egg=django_pagination
|
||||
-- stdout: --------------------
|
||||
-f git://github.com/jezdez/django-pagination.git#egg=django_pagination
|
||||
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...-dev
|
||||
...
|
||||
|
||||
Now what about Mercurial::
|
||||
|
||||
>>> reset_env()
|
||||
>>> env = get_env()
|
||||
>>> result = env.run('hg', 'clone', '-r', 'f8f7eaf275c5', 'http://bitbucket.org/jezdez/django-dbtemplates/', 'django-dbtemplates')
|
||||
>>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
... cwd=os.path.join(env.base_path, 'django-dbtemplates'))
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
|
||||
...
|
||||
|
||||
>>> result = run_pip('freeze', '-f', 'hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
|
||||
-- stdout: --------------------
|
||||
-f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
|
||||
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
|
||||
...
|
||||
|
||||
Heck, now look in the Bazaar::
|
||||
|
||||
>>> reset_env()
|
||||
>>> env = get_env()
|
||||
>>> result = env.run('bzr', 'checkout', '-r', '174', 'http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/', 'django-wikiapp')
|
||||
>>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
|
||||
... cwd=os.path.join(env.base_path, 'django-wikiapp'))
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
|
||||
...
|
||||
|
||||
>>> result = run_pip('freeze', '-f', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() -E .../test-scratch freeze -f bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
|
||||
-- stdout: --------------------
|
||||
-f bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
|
||||
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
|
||||
...
|
||||
|
||||
|
||||
Test that wsgiref (from global site-packages) is reported normally, but not with --local::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'initools==0.2')
|
||||
>>> result = run_pip('freeze', expect_stderr=True)
|
||||
>>> print result
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
wsgiref==...
|
||||
<BLANKLINE>
|
||||
>>> result2 = run_pip('freeze', '--local', expect_stderr=True)
|
||||
>>> print result2
|
||||
Script result: ...ython... pip.main() .../test-scratch freeze --local
|
||||
-- stdout: --------------------
|
||||
INITools==0.2
|
||||
<BLANKLINE>
|
|
@ -1,6 +1,9 @@
|
|||
'''
|
||||
Tests for the proxy support in pip::
|
||||
'''
|
||||
"""
|
||||
Tests for the proxy support in pip.
|
||||
|
||||
TODO shouldn't need to hack sys.path in here.
|
||||
|
||||
"""
|
||||
import os, sys
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
|
@ -14,17 +17,19 @@ def new_getpass(prompt, answer='passwd'):
|
|||
print '%s%s' % (prompt, answer)
|
||||
return answer
|
||||
|
||||
def test_0():
|
||||
'''
|
||||
Check we are running proper version of pip in run_pip::
|
||||
'''
|
||||
def test_correct_pip_version():
|
||||
"""
|
||||
Check we are importing pip from the right place.
|
||||
|
||||
"""
|
||||
base = os.path.dirname(here)
|
||||
assert pip.__file__.startswith(base), pip.__file__
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
Remove proxy from environ:
|
||||
'''
|
||||
def test_remove_proxy():
|
||||
"""
|
||||
Test removing proxy from environ.
|
||||
|
||||
"""
|
||||
if 'HTTP_PROXY' in os.environ:
|
||||
del os.environ['HTTP_PROXY']
|
||||
assert get_proxy() == None
|
||||
|
@ -35,10 +40,12 @@ def test_1():
|
|||
assert get_proxy('server.com:80') == 'server.com:80'
|
||||
assert get_proxy('user:passwd@server.com:3128') == 'user:passwd@server.com:3128'
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Now, a quick monkeypatch for getpass.getpass, to avoid asking for a password::
|
||||
'''
|
||||
def test_get_proxy():
|
||||
"""
|
||||
Test get_proxy returns correct proxy info.
|
||||
|
||||
"""
|
||||
# monkeypatch getpass.getpass, to avoid asking for a password
|
||||
old_getpass = getpass.getpass
|
||||
getpass.getpass = new_getpass
|
||||
|
||||
|
@ -46,6 +53,6 @@ def test_2():
|
|||
assert get_proxy('user:@server.com:3128') == 'user:@server.com:3128'
|
||||
assert get_proxy('user@server.com:3128') == 'user:passwd@server.com:3128'
|
||||
|
||||
# Undo monkeypatch:
|
||||
# Undo monkeypatch
|
||||
getpass.getpass = old_getpass
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
Tests for the proxy support in pip::
|
||||
|
||||
>>> import os
|
||||
>>> from pip.basecommand import get_proxy
|
||||
|
||||
Remove proxy from environ:
|
||||
|
||||
>>> if 'HTTP_PROXY' in os.environ:
|
||||
... del os.environ['HTTP_PROXY']
|
||||
|
||||
>>> print get_proxy()
|
||||
None
|
||||
>>> os.environ['HTTP_PROXY'] = 'user:pwd@server.com:port'
|
||||
>>> get_proxy()
|
||||
'user:pwd@server.com:port'
|
||||
>>> del os.environ['HTTP_PROXY']
|
||||
>>> get_proxy('server.com')
|
||||
'server.com'
|
||||
>>> get_proxy('server.com:80')
|
||||
'server.com:80'
|
||||
>>> get_proxy('user:passwd@server.com:3128')
|
||||
'user:passwd@server.com:3128'
|
||||
|
||||
Now, a quick monkeypatch for getpass.getpass, to avoid asking for a password::
|
||||
|
||||
>>> import getpass
|
||||
>>> old_getpass = getpass.getpass
|
||||
>>> def new_getpass(prompt, answer='passwd'):
|
||||
... print '%s%s' % (prompt, answer)
|
||||
... return answer
|
||||
>>> getpass.getpass = new_getpass
|
||||
|
||||
Test it:
|
||||
|
||||
>>> get_proxy('user:@server.com:3128')
|
||||
'user:@server.com:3128'
|
||||
>>> get_proxy('user@server.com:3128')
|
||||
Password for user@server.com:3128: passwd
|
||||
'user:passwd@server.com:3128'
|
||||
|
||||
Undo monkeypatch:
|
||||
|
||||
>>> getpass.getpass = old_getpass
|
|
@ -3,16 +3,17 @@ import os
|
|||
import textwrap
|
||||
from test_pip import base_path, reset_env, run_pip, pyversion, lib_py, write_file
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
Some tests of requirement files::
|
||||
'''
|
||||
def test_requirements_file():
|
||||
"""
|
||||
Test installing from a requirements file.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
write_file('initools-req.txt', textwrap.dedent('''\
|
||||
write_file('initools-req.txt', textwrap.dedent("""\
|
||||
INITools==0.2
|
||||
# and something else to test out:
|
||||
simplejson<=1.7.4
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-r', 'initools-req.txt')
|
||||
assert len(result.wildcard_matches('lib/python*/site-packages/INITools-0.2-py*.egg-info')) == 1
|
||||
assert len(result.wildcard_matches('lib/python*/site-packages/initools')) == 1
|
||||
|
@ -20,17 +21,18 @@ def test_1():
|
|||
assert len(dirs) == 2
|
||||
assert dirs[0].dir, dirs[1].dir == (True, True)
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Now with more than one file::
|
||||
'''
|
||||
def test_multiple_requirements_files():
|
||||
"""
|
||||
Test installing from multiple nested requirements files.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
write_file('initools-req.txt', textwrap.dedent('''\
|
||||
write_file('initools-req.txt', textwrap.dedent("""\
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk@3139#egg=INITools-dev
|
||||
-r simplejson-req.txt'''))
|
||||
write_file('simplejson-req.txt', textwrap.dedent('''\
|
||||
-r simplejson-req.txt"""))
|
||||
write_file('simplejson-req.txt', textwrap.dedent("""\
|
||||
simplejson<=1.7.4
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-r', 'initools-req.txt')
|
||||
assert len(result.wildcard_matches('lib/python*/site-packages/simplejson*')) == 2
|
||||
assert 'src/initools' in result.files_created
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> import os
|
||||
>>> from __main__ import base_path, reset_env, run_pip, pyversion, lib_py, write_file
|
||||
|
||||
Some tests of requirement files::
|
||||
|
||||
>>> reset_env()
|
||||
>>> write_file('initools-req.txt', '''\
|
||||
... INITools==0.2
|
||||
... # and something else to test out:
|
||||
... simplejson<=1.7.4
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-r', 'initools-req.txt')
|
||||
>>> len(result.wildcard_matches('lib/python*/site-packages/INITools-0.2-py*.egg-info'))
|
||||
1
|
||||
>>> len(result.wildcard_matches('lib/python*/site-packages/initools'))
|
||||
1
|
||||
>>> dirs = result.wildcard_matches('lib/python*/site-packages/simplejson*')
|
||||
>>> len(dirs)
|
||||
2
|
||||
>>> dirs[0].dir, dirs[1].dir
|
||||
(True, True)
|
||||
|
||||
Now with more than one file::
|
||||
|
||||
>>> reset_env()
|
||||
>>> write_file('initools-req.txt', '''\
|
||||
... -e svn+http://svn.colorstudy.com/INITools/trunk@3139#egg=INITools-dev
|
||||
... -r simplejson-req.txt''')
|
||||
>>> write_file('simplejson-req.txt', '''\
|
||||
... simplejson<=1.7.4
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-r', 'initools-req.txt')
|
||||
>>> len(result.wildcard_matches('lib/python*/site-packages/simplejson*'))
|
||||
2
|
||||
>>> assert 'src/initools' in result.files_created
|
||||
|
|
@ -6,20 +6,22 @@ from pip.commands.search import compare_versions, highest_version, transform_hit
|
|||
from test_pip import run_pip, reset_env
|
||||
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
Test version comparison::
|
||||
'''
|
||||
def test_version_compare():
|
||||
"""
|
||||
Test version comparison.
|
||||
|
||||
"""
|
||||
assert compare_versions('1.0', '1.1') == -1
|
||||
assert compare_versions('1.1', '1.0') == 1
|
||||
assert compare_versions('1.1a1', '1.1') == -1
|
||||
assert highest_version(['1.0', '2.0', '0.1']) == '2.0'
|
||||
assert highest_version(['1.0a1', '1.0']) == '1.0'
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Test transformation of data structures (pypi xmlrpc to custom list)::
|
||||
'''
|
||||
def test_pypi_xml_transformation():
|
||||
"""
|
||||
Test transformation of data structures (pypi xmlrpc to custom list).
|
||||
|
||||
"""
|
||||
pypi_hits = [{'_pypi_ordering': 100, 'name': 'foo', 'summary': 'foo summary', 'version': '1.0'},
|
||||
{'_pypi_ordering': 200, 'name': 'foo', 'summary': 'foo summary v2', 'version': '2.0'},
|
||||
{'_pypi_ordering': 50, 'name': 'bar', 'summary': 'bar summary', 'version': '1.0'}]
|
||||
|
@ -27,10 +29,11 @@ def test_2():
|
|||
{'score': 50, 'versions': ['1.0'], 'name': 'bar', 'summary': 'bar summary'}]
|
||||
assert expected == transform_hits(pypi_hits)
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
End to end test::
|
||||
'''
|
||||
def test_search():
|
||||
"""
|
||||
End to end test of search command.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
output = run_pip('search', 'pip', expect_error=True)
|
||||
assert 'pip installs packages' in output.stdout
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from pip.commands.search import compare_versions, highest_version, transform_hits
|
||||
>>> from __main__ import run_pip
|
||||
|
||||
Test version comparison::
|
||||
|
||||
>>> compare_versions('1.0', '1.1')
|
||||
-1
|
||||
>>> compare_versions('1.1', '1.0')
|
||||
1
|
||||
>>> compare_versions('1.1a1', '1.1')
|
||||
-1
|
||||
>>> highest_version(['1.0', '2.0', '0.1'])
|
||||
'2.0'
|
||||
>>> highest_version(['1.0a1', '1.0'])
|
||||
'1.0'
|
||||
|
||||
Test transformation of data structures (pypi xmlrpc to custom list)::
|
||||
|
||||
>>> pypi_hits = [{'_pypi_ordering': 100, 'name': 'foo', 'summary': 'foo summary', 'version': '1.0'},
|
||||
... {'_pypi_ordering': 200, 'name': 'foo', 'summary': 'foo summary v2', 'version': '2.0'},
|
||||
... {'_pypi_ordering': 50, 'name': 'bar', 'summary': 'bar summary', 'version': '1.0'}]
|
||||
|
||||
>>> print transform_hits(pypi_hits)
|
||||
[{'score': 200, 'versions': ['1.0', '2.0'], 'name': 'foo', 'summary': 'foo summary v2'}, {'score': 50, 'versions': ['1.0'], 'name': 'bar', 'summary': 'bar summary'}]
|
||||
|
||||
End to end test::
|
||||
|
||||
>>> output = run_pip('search', 'pip', expect_error=True)
|
||||
>>> assert('pip installs packages' in output.stdout)
|
|
@ -7,20 +7,22 @@ from test_pip import here, reset_env, run_pip, pyversion, lib_py, get_env, diff_
|
|||
site_pkg = join(lib_py, 'site-packages')
|
||||
easy_install_pth = join(site_pkg, 'easy-install.pth')
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
Simple install and uninstall::
|
||||
'''
|
||||
def test_simple_uninstall():
|
||||
"""
|
||||
Test simple install and uninstall.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert join(site_pkg, 'initools') in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = run_pip('uninstall', 'INITools', '-y', expect_error=True)
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
Uninstall an easy_installed package with scripts::
|
||||
'''
|
||||
def test_uninstall_with_scripts():
|
||||
"""
|
||||
Uninstall an easy_installed package with scripts.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
result = env.run(join(env.base_path, 'bin', 'easy_install'), 'PyLogo')
|
||||
|
@ -28,11 +30,12 @@ def test_2():
|
|||
result2 = run_pip('uninstall', 'pylogo', '-y', expect_error=True)
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
def test_uninstall_namespace_package():
|
||||
"""
|
||||
Uninstall a distribution with a namespace package without clobbering
|
||||
the namespace and everything in it::
|
||||
'''
|
||||
the namespace and everything in it.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'pd.requires==0.0.3', expect_error=True)
|
||||
assert join(site_pkg, 'pd') in result.files_created, sorted(result.files_created.keys())
|
||||
|
@ -40,20 +43,22 @@ def test_3():
|
|||
assert join(site_pkg, 'pd') not in result2.files_deleted, sorted(result2.files_deleted.keys())
|
||||
assert join(site_pkg, 'pd', 'find') in result2.files_deleted, sorted(result2.files_deleted.keys())
|
||||
|
||||
def test_4():
|
||||
'''
|
||||
Uninstall a package with more files (script entry points, extra directories)::
|
||||
'''
|
||||
def test_uninstall_console_scripts():
|
||||
"""
|
||||
Test uninstalling a package with more files (console_script entry points, extra directories).
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'virtualenv', expect_error=True)
|
||||
assert ('bin/virtualenv') in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = run_pip('uninstall', 'virtualenv', '-y', expect_error=True)
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_5():
|
||||
'''
|
||||
Same, but easy_installed::
|
||||
'''
|
||||
def test_uninstall_easy_installed_console_scripts():
|
||||
"""
|
||||
Test uninstalling package with console_scripts that is easy_installed.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
result = env.run(join(env.base_path, 'bin', 'easy_install'), 'virtualenv')
|
||||
|
@ -61,10 +66,11 @@ def test_5():
|
|||
result2 = run_pip('uninstall', 'virtualenv', '-y', expect_error=True)
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_6():
|
||||
'''
|
||||
Uninstall an editable installation from svn::
|
||||
'''
|
||||
def test_uninstall_editable_from_svn():
|
||||
"""
|
||||
Test uninstalling an editable installation from svn.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
|
||||
egg_link = result.files_created[join(site_pkg, 'INITools.egg-link')]
|
||||
|
@ -72,10 +78,11 @@ def test_6():
|
|||
assert ('src/initools' in result2.files_after), 'oh noes, pip deleted my sources!'
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['src/initools', 'build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_7():
|
||||
'''
|
||||
Editable install from existing source outside the venv::
|
||||
'''
|
||||
def test_uninstall_editable_with_source_outside_venv():
|
||||
"""
|
||||
Test uninstalling editable install from existing source outside the venv.
|
||||
|
||||
"""
|
||||
tmpdir = mkdtemp()
|
||||
reset_env()
|
||||
env = get_env()
|
||||
|
@ -85,16 +92,17 @@ def test_7():
|
|||
result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
|
||||
assert diff_states(result.files_before, result3.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_8():
|
||||
'''
|
||||
Uninstall from a requirements file::
|
||||
'''
|
||||
def test_uninstall_from_reqs_file():
|
||||
"""
|
||||
Test uninstall from a requirements file.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
write_file('test-req.txt', textwrap.dedent('''\
|
||||
write_file('test-req.txt', textwrap.dedent("""\
|
||||
-e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
|
||||
# and something else to test out:
|
||||
PyLogo<0.4
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-r', 'test-req.txt')
|
||||
result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
|
||||
assert diff_states(result.files_before, result2.files_after, ignore=['build', 'src/initools']).values() == [{}, {}, {}]
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from __main__ import here, reset_env, run_pip, pyversion, lib_py, get_env, diff_states, write_file
|
||||
>>> from os.path import join
|
||||
>>> from tempfile import mkdtemp
|
||||
>>> site_pkg = join(lib_py, 'site-packages')
|
||||
>>> easy_install_pth = join(site_pkg, 'easy-install.pth')
|
||||
|
||||
Simple install and uninstall::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
>>> assert join(site_pkg, 'initools') in result.files_created, sorted(result.files_created.keys())
|
||||
>>> result2 = run_pip('uninstall', 'INITools', '-y', expect_error=True)
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Uninstall an easy_installed package with scripts::
|
||||
|
||||
>>> reset_env()
|
||||
>>> env = get_env()
|
||||
>>> result = env.run(join(env.base_path, 'bin', 'easy_install'), 'PyLogo')
|
||||
>>> assert('PyLogo' in result.files_updated[easy_install_pth].bytes), result.files_after[easy_install_pth].bytes
|
||||
>>> result2 = run_pip('uninstall', 'pylogo', '-y', expect_error=True)
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Uninstall a distribution with a namespace package without clobbering
|
||||
the namespace and everything in it::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'pd.requires==0.0.3', expect_error=True)
|
||||
>>> assert join(site_pkg, 'pd') in result.files_created, sorted(result.files_created.keys())
|
||||
>>> result2 = run_pip('uninstall', 'pd.find', '-y', expect_error=True)
|
||||
>>> assert join(site_pkg, 'pd') not in result2.files_deleted, sorted(result2.files_deleted.keys())
|
||||
>>> assert join(site_pkg, 'pd', 'find') in result2.files_deleted, sorted(result2.files_deleted.keys())
|
||||
|
||||
Uninstall a package with more files (script entry points, extra directories)::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'virtualenv', expect_error=True)
|
||||
>>> assert ('bin/virtualenv') in result.files_created, sorted(result.files_created.keys())
|
||||
>>> result2 = run_pip('uninstall', 'virtualenv', '-y', expect_error=True)
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Same, but easy_installed::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = env.run(join(env.base_path, 'bin', 'easy_install'), 'virtualenv')
|
||||
>>> assert ('bin/virtualenv') in result.files_created, sorted(result.files_created.keys())
|
||||
>>> result2 = run_pip('uninstall', 'virtualenv', '-y', expect_error=True)
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Uninstall an editable installation from svn::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
|
||||
>>> egg_link = result.files_created[join(site_pkg, 'INITools.egg-link')]
|
||||
>>> result2 = run_pip('uninstall', '-y', 'initools', expect_error=True)
|
||||
>>> assert ('src/initools' in result2.files_after), 'oh noes, pip deleted my sources!'
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['src/initools', 'build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Editable install from existing source outside the venv::
|
||||
|
||||
>>> reset_env()
|
||||
>>> tmpdir = mkdtemp()
|
||||
>>> result = env.run('hg', 'clone', 'http://bitbucket.org/ianb/virtualenv/', tmpdir)
|
||||
>>> result2 = run_pip('install', '-e', tmpdir)
|
||||
>>> assert (join(site_pkg, 'virtualenv.egg-link') in result2.files_created), result2.files_created.keys()
|
||||
>>> result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
|
||||
>>> diff_states(result.files_before, result3.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Uninstall from a requirements file::
|
||||
|
||||
>>> reset_env()
|
||||
>>> write_file('test-req.txt', '''\
|
||||
... -e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
|
||||
... # and something else to test out:
|
||||
... PyLogo<0.4
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-r', 'test-req.txt')
|
||||
>>> result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
|
||||
>>> diff_states(result.files_before, result2.files_after, ignore=['build', 'src/initools']).values()
|
||||
[{}, {}, {}]
|
|
@ -3,37 +3,41 @@ from os.path import join
|
|||
import textwrap
|
||||
from test_pip import here, reset_env, run_pip, pyversion, lib_py, get_env, diff_states, write_file
|
||||
|
||||
def test_1():
|
||||
'''
|
||||
No upgrade if not specifically requested::
|
||||
'''
|
||||
def test_no_upgrade_unless_requested():
|
||||
"""
|
||||
No upgrade if not specifically requested.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
result2 = run_pip('install', 'INITools', expect_error=True)
|
||||
assert not result2.files_created, 'pip install INITools upgraded when it should not have'
|
||||
|
||||
def test_2():
|
||||
'''
|
||||
It does upgrade to specific version requested::
|
||||
'''
|
||||
def test_upgrade_to_specific_version():
|
||||
"""
|
||||
It does upgrade to specific version requested.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
result2 = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert result2.files_created, 'pip install with specific version did not upgrade'
|
||||
|
||||
def test_3():
|
||||
'''
|
||||
And it does upgrade if requested::
|
||||
'''
|
||||
def test_upgrade_if_requested():
|
||||
"""
|
||||
And it does upgrade if requested.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
result2 = run_pip('install', '--upgrade', 'INITools', expect_error=True)
|
||||
assert result2.files_created, 'pip install --upgrade did not upgrade'
|
||||
|
||||
def test_4():
|
||||
'''
|
||||
Automatic uninstall-before-upgrade::
|
||||
'''
|
||||
def test_uninstall_before_upgrade():
|
||||
"""
|
||||
Automatic uninstall-before-upgrade.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
result = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert join(lib_py + 'site-packages', 'initools') in result.files_created, sorted(result.files_created.keys())
|
||||
|
@ -42,31 +46,33 @@ def test_4():
|
|||
result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
|
||||
assert diff_states(result.files_before, result3.files_after, ignore=['build']).values() == [{}, {}, {}]
|
||||
|
||||
def test_5():
|
||||
'''
|
||||
Upgrade from a requirements file::
|
||||
'''
|
||||
def test_upgrade_from_reqs_file():
|
||||
"""
|
||||
Upgrade from a requirements file.
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
write_file('test-req.txt', textwrap.dedent('''\
|
||||
write_file('test-req.txt', textwrap.dedent("""\
|
||||
PyLogo<0.4
|
||||
# and something else to test out:
|
||||
INITools==0.3
|
||||
'''))
|
||||
"""))
|
||||
result = run_pip('install', '-r', 'test-req.txt')
|
||||
write_file('test-req.txt', textwrap.dedent('''\
|
||||
write_file('test-req.txt', textwrap.dedent("""\
|
||||
PyLogo
|
||||
# and something else to test out:
|
||||
INITools
|
||||
'''))
|
||||
"""))
|
||||
result2 = run_pip('install', '--upgrade', '-r', 'test-req.txt')
|
||||
result3 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
|
||||
assert diff_states(result.files_before, result3.files_after, ignore=['build', 'test-req.txt']).values() == [{}, {}, {}]
|
||||
|
||||
def test_6():
|
||||
'''
|
||||
Test uninstall-rollback (using test package with a setup.py crafted to
|
||||
fail on install)::
|
||||
'''
|
||||
def test_uninstall_rollback():
|
||||
"""
|
||||
Test uninstall-rollback (using test package with a setup.py
|
||||
crafted to fail on install).
|
||||
|
||||
"""
|
||||
reset_env()
|
||||
env = get_env()
|
||||
find_links = 'file://' + join(here, 'packages')
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
Basic setup::
|
||||
|
||||
>>> from __main__ import here, reset_env, run_pip, pyversion, lib_py, get_env, diff_states, write_file
|
||||
>>> from os.path import join
|
||||
|
||||
No upgrade if not specifically requested::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
>>> result2 = run_pip('install', 'INITools', expect_error=True)
|
||||
>>> assert not result2.files_created, 'pip install INITools upgraded when it should not have'
|
||||
|
||||
It does upgrade to specific version requested::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
>>> result2 = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
>>> assert result2.files_created, 'pip install with specific version did not upgrade'
|
||||
|
||||
And it does upgrade if requested::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==0.1', expect_error=True)
|
||||
>>> result2 = run_pip('install', '--upgrade', 'INITools', expect_error=True)
|
||||
>>> assert result2.files_created, 'pip install --upgrade did not upgrade'
|
||||
|
||||
Automatic uninstall-before-upgrade::
|
||||
|
||||
>>> reset_env()
|
||||
>>> result = run_pip('install', 'INITools==0.2', expect_error=True)
|
||||
>>> assert join(lib_py + 'site-packages', 'initools') in result.files_created, sorted(result.files_created.keys())
|
||||
>>> result2 = run_pip('install', 'INITools==0.3', expect_error=True)
|
||||
>>> assert result2.files_created, 'upgrade to INITools 0.3 failed'
|
||||
>>> result3 = run_pip('uninstall', 'initools', '-y', expect_error=True)
|
||||
>>> diff_states(result.files_before, result3.files_after, ignore=['build']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Upgrade from a requirements file::
|
||||
|
||||
>>> reset_env()
|
||||
>>> write_file('test-req.txt', '''\
|
||||
... PyLogo<0.4
|
||||
... # and something else to test out:
|
||||
... INITools==0.3
|
||||
... ''')
|
||||
>>> result = run_pip('install', '-r', 'test-req.txt')
|
||||
>>> write_file('test-req.txt', '''\
|
||||
... PyLogo
|
||||
... # and something else to test out:
|
||||
... INITools
|
||||
... ''')
|
||||
>>> result2 = run_pip('install', '--upgrade', '-r', 'test-req.txt')
|
||||
>>> result3 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
|
||||
>>> diff_states(result.files_before, result3.files_after, ignore=['build', 'test-req.txt']).values()
|
||||
[{}, {}, {}]
|
||||
|
||||
Test uninstall-rollback (using test package with a setup.py crafted to
|
||||
fail on install)::
|
||||
|
||||
>>> reset_env()
|
||||
>>> env = get_env()
|
||||
>>> find_links = 'file://' + join(here, 'packages')
|
||||
>>> result = run_pip('install', '-f', find_links, '--no-index', 'broken==0.1')
|
||||
>>> assert (join(lib_py, 'site-packages', 'broken.py') in result.files_created), result.files_created.keys()
|
||||
>>> result2 = run_pip('install', '-f', find_links, '--no-index', 'broken==0.2broken', expect_error=True)
|
||||
>>> assert result2.returncode == 1, str(result2)
|
||||
>>> env.run(join(env.base_path, 'bin', 'python'), '-c', "import broken; print broken.VERSION").stdout
|
||||
'0.1\n'
|
||||
>>> diff_states(result.files_after, result2.files_after, ignore=['build', 'pip-log.txt']).values()
|
||||
[{}, {}, {}]
|
Loading…
Reference in New Issue