提交 f9a3b97b 编写于 作者: D Donald Stufft

Explicitly pass around a directory for tests.lib.local_repos

上级 0c42245f
...@@ -7,7 +7,7 @@ from tests.lib.path import Path ...@@ -7,7 +7,7 @@ from tests.lib.path import Path
from tests.lib.local_repos import local_checkout from tests.lib.local_repos import local_checkout
def test_create_bundle(script): def test_create_bundle(script, tmpdir):
""" """
Test making a bundle. We'll grab one package from the filesystem Test making a bundle. We'll grab one package from the filesystem
(the FSPkg dummy package), one from vcs (initools) and one from an (the FSPkg dummy package), one from vcs (initools) and one from an
...@@ -19,7 +19,7 @@ def test_create_bundle(script): ...@@ -19,7 +19,7 @@ def test_create_bundle(script):
pkg_lines = textwrap.dedent('''\ pkg_lines = textwrap.dedent('''\
-e %s -e %s
-e %s#egg=initools-dev -e %s#egg=initools-dev
pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
script.scratch_path.join("bundle-req.txt").write(pkg_lines) script.scratch_path.join("bundle-req.txt").write(pkg_lines)
# Create a bundle in env.scratch_path/ test.pybundle # Create a bundle in env.scratch_path/ test.pybundle
result = script.pip('bundle', '-r', script.scratch_path/ 'bundle-req.txt', script.scratch_path/ 'test.pybundle') result = script.pip('bundle', '-r', script.scratch_path/ 'bundle-req.txt', script.scratch_path/ 'test.pybundle')
...@@ -32,7 +32,7 @@ def test_create_bundle(script): ...@@ -32,7 +32,7 @@ def test_create_bundle(script):
assert 'build/pip/' in files assert 'build/pip/' in files
def test_cleanup_after_create_bundle(script): def test_cleanup_after_create_bundle(script, tmpdir):
""" """
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/. Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
...@@ -41,7 +41,7 @@ def test_cleanup_after_create_bundle(script): ...@@ -41,7 +41,7 @@ def test_cleanup_after_create_bundle(script):
args = ['install'] args = ['install']
args.extend(['-e', args.extend(['-e',
'%s#egg=pip-test-package' % '%s#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git')]) local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))])
script.pip(*args) script.pip(*args)
build = script.venv_path/"build" build = script.venv_path/"build"
src = script.venv_path/"src" src = script.venv_path/"src"
...@@ -53,7 +53,7 @@ def test_cleanup_after_create_bundle(script): ...@@ -53,7 +53,7 @@ def test_cleanup_after_create_bundle(script):
pkg_lines = textwrap.dedent('''\ pkg_lines = textwrap.dedent('''\
-e %s -e %s
-e %s#egg=initools-dev -e %s#egg=initools-dev
pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
script.scratch_path.join("bundle-req.txt").write(pkg_lines) script.scratch_path.join("bundle-req.txt").write(pkg_lines)
script.pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle') script.pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
build_bundle = script.scratch_path/"build-bundle" build_bundle = script.scratch_path/"build-bundle"
......
...@@ -58,15 +58,15 @@ def test_freeze_basic(script): ...@@ -58,15 +58,15 @@ def test_freeze_basic(script):
_check_output(result, expected) _check_output(result, expected)
def test_freeze_svn(script): def test_freeze_svn(script, tmpdir):
"""Test freezing a svn checkout""" """Test freezing a svn checkout"""
checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk') checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))
#svn internally stores windows drives as uppercase; we'll match that. #svn internally stores windows drives as uppercase; we'll match that.
checkout_path = checkout_path.replace('c:', 'C:') checkout_path = checkout_path.replace('c:', 'C:')
result = script.run('svn', 'co', '-r10', result = script.run('svn', 'co', '-r10',
local_repo('svn+http://svn.colorstudy.com/INITools/trunk'), local_repo('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
'initools-trunk') 'initools-trunk')
result = script.run('python', 'setup.py', 'develop', result = script.run('python', 'setup.py', 'develop',
cwd=script.scratch_path/ 'initools-trunk', expect_stderr=True) cwd=script.scratch_path/ 'initools-trunk', expect_stderr=True)
...@@ -79,12 +79,12 @@ def test_freeze_svn(script): ...@@ -79,12 +79,12 @@ def test_freeze_svn(script):
_check_output(result, expected) _check_output(result, expected)
def test_freeze_git_clone(script): def test_freeze_git_clone(script, tmpdir):
""" """
Test freezing a Git clone. Test freezing a Git clone.
""" """
result = script.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git'), 'pip-test-package') result = script.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")), 'pip-test-package')
result = script.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458', result = script.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
cwd=script.scratch_path / 'pip-test-package', expect_stderr=True) cwd=script.scratch_path / 'pip-test-package', expect_stderr=True)
result = script.run('python', 'setup.py', 'develop', result = script.run('python', 'setup.py', 'develop',
...@@ -94,29 +94,29 @@ def test_freeze_git_clone(script): ...@@ -94,29 +94,29 @@ def test_freeze_git_clone(script):
Script result: ...pip freeze Script result: ...pip freeze
-- stdout: -------------------- -- stdout: --------------------
...-e %s@...#egg=pip_test_package-... ...-e %s@...#egg=pip_test_package-...
...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git')) ...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")))
_check_output(result, expected) _check_output(result, expected)
result = script.pip('freeze', '-f', result = script.pip('freeze', '-f',
'%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git'), '%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
expect_stderr=True) expect_stderr=True)
expected = textwrap.dedent("""\ expected = textwrap.dedent("""\
Script result: pip freeze -f %(repo)s#egg=pip_test_package Script result: pip freeze -f %(repo)s#egg=pip_test_package
-- stdout: -------------------- -- stdout: --------------------
-f %(repo)s#egg=pip_test_package... -f %(repo)s#egg=pip_test_package...
-e %(repo)s@...#egg=pip_test_package-0.1.1 -e %(repo)s@...#egg=pip_test_package-0.1.1
...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git')}) ...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))})
_check_output(result, expected) _check_output(result, expected)
def test_freeze_mercurial_clone(script): def test_freeze_mercurial_clone(script, tmpdir):
""" """
Test freezing a Mercurial clone. Test freezing a Mercurial clone.
""" """
result = script.run('hg', 'clone', result = script.run('hg', 'clone',
'-r', 'c9963c111e7c', '-r', 'c9963c111e7c',
local_repo('hg+http://bitbucket.org/pypa/pip-test-package'), local_repo('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
'pip-test-package') 'pip-test-package')
result = script.run('python', 'setup.py', 'develop', result = script.run('python', 'setup.py', 'develop',
cwd=script.scratch_path/'pip-test-package', expect_stderr=True) cwd=script.scratch_path/'pip-test-package', expect_stderr=True)
...@@ -125,33 +125,33 @@ def test_freeze_mercurial_clone(script): ...@@ -125,33 +125,33 @@ def test_freeze_mercurial_clone(script):
Script result: ...pip freeze Script result: ...pip freeze
-- stdout: -------------------- -- stdout: --------------------
...-e %s@...#egg=pip_test_package-... ...-e %s@...#egg=pip_test_package-...
...""" % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package')) ...""" % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")))
_check_output(result, expected) _check_output(result, expected)
result = script.pip('freeze', '-f', result = script.pip('freeze', '-f',
'%s#egg=pip_test_package' % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package'), '%s#egg=pip_test_package' % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
expect_stderr=True) expect_stderr=True)
expected = textwrap.dedent("""\ expected = textwrap.dedent("""\
Script result: ...pip freeze -f %(repo)s#egg=pip_test_package Script result: ...pip freeze -f %(repo)s#egg=pip_test_package
-- stdout: -------------------- -- stdout: --------------------
-f %(repo)s#egg=pip_test_package -f %(repo)s#egg=pip_test_package
...-e %(repo)s@...#egg=pip_test_package-dev ...-e %(repo)s@...#egg=pip_test_package-dev
...""" % {'repo': local_checkout('hg+http://bitbucket.org/pypa/pip-test-package')}) ...""" % {'repo': local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache"))})
_check_output(result, expected) _check_output(result, expected)
def test_freeze_bazaar_clone(script): def test_freeze_bazaar_clone(script, tmpdir):
""" """
Test freezing a Bazaar clone. Test freezing a Bazaar clone.
""" """
checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1') checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache"))
#bzr internally stores windows drives as uppercase; we'll match that. #bzr internally stores windows drives as uppercase; we'll match that.
checkout_pathC = checkout_path.replace('c:', 'C:') checkout_pathC = checkout_path.replace('c:', 'C:')
result = script.run('bzr', 'checkout', '-r', '174', result = script.run('bzr', 'checkout', '-r', '174',
local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'), local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
'django-wikiapp') 'django-wikiapp')
result = script.run('python', 'setup.py', 'develop', result = script.run('python', 'setup.py', 'develop',
cwd=script.scratch_path/'django-wikiapp') cwd=script.scratch_path/'django-wikiapp')
......
...@@ -46,18 +46,18 @@ def test_editable_install(script): ...@@ -46,18 +46,18 @@ def test_editable_install(script):
assert not result.files_updated, result.files_updated assert not result.files_updated, result.files_updated
def test_install_editable_from_svn(script): def test_install_editable_from_svn(script, tmpdir):
""" """
Test checking out from svn. Test checking out from svn.
""" """
result = script.pip('install', result = script.pip('install',
'-e', '-e',
'%s#egg=initools-dev' % '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
result.assert_installed('INITools', with_files=['.svn']) result.assert_installed('INITools', with_files=['.svn'])
def test_download_editable_to_custom_path(script): def test_download_editable_to_custom_path(script, tmpdir):
""" """
Test downloading an editable using a relative custom src folder. Test downloading an editable using a relative custom src folder.
""" """
...@@ -65,7 +65,7 @@ def test_download_editable_to_custom_path(script): ...@@ -65,7 +65,7 @@ def test_download_editable_to_custom_path(script):
result = script.pip('install', result = script.pip('install',
'-e', '-e',
'%s#egg=initools-dev' % '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
'--src', '--src',
'customsrc', 'customsrc',
'--download', '--download',
...@@ -80,21 +80,21 @@ def test_download_editable_to_custom_path(script): ...@@ -80,21 +80,21 @@ def test_download_editable_to_custom_path(script):
assert customdl_files_created assert customdl_files_created
def test_editable_no_install_followed_by_no_download(script): def test_editable_no_install_followed_by_no_download(script, tmpdir):
""" """
Test installing an editable in two steps (first with --no-install, then with --no-download). Test installing an editable in two steps (first with --no-install, then with --no-download).
""" """
result = script.pip('install', result = script.pip('install',
'-e', '-e',
'%s#egg=initools-dev' % '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
'--no-install', expect_error=True) '--no-install', expect_error=True)
result.assert_installed('INITools', without_egg_link=True, with_files=['.svn']) result.assert_installed('INITools', without_egg_link=True, with_files=['.svn'])
result = script.pip('install', result = script.pip('install',
'-e', '-e',
'%s#egg=initools-dev' % '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
'--no-download', expect_error=True) '--no-download', expect_error=True)
result.assert_installed('INITools', without_files=[curdir, '.svn']) result.assert_installed('INITools', without_files=[curdir, '.svn'])
...@@ -140,58 +140,58 @@ def test_install_dev_version_from_pypi(script): ...@@ -140,58 +140,58 @@ def test_install_dev_version_from_pypi(script):
assert (script.site_packages / 'initools') in result.files_created, str(result.stdout) assert (script.site_packages / 'initools') in result.files_created, str(result.stdout)
def test_install_editable_from_git(script): def test_install_editable_from_git(script, tmpdir):
""" """
Test cloning from Git. Test cloning from Git.
""" """
args = ['install'] args = ['install']
args.extend(['-e', args.extend(['-e',
'%s#egg=pip-test-package' % '%s#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git')]) local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))])
result = script.pip(*args, **{"expect_error": True}) result = script.pip(*args, **{"expect_error": True})
result.assert_installed('pip-test-package', with_files=['.git']) result.assert_installed('pip-test-package', with_files=['.git'])
def test_install_editable_from_hg(script): def test_install_editable_from_hg(script, tmpdir):
""" """
Test cloning from Mercurial. Test cloning from Mercurial.
""" """
result = script.pip('install', '-e', result = script.pip('install', '-e',
'%s#egg=ScriptTest' % '%s#egg=ScriptTest' %
local_checkout('hg+https://bitbucket.org/ianb/scripttest'), local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
expect_error=True) expect_error=True)
result.assert_installed('ScriptTest', with_files=['.hg']) result.assert_installed('ScriptTest', with_files=['.hg'])
def test_vcs_url_final_slash_normalization(script): def test_vcs_url_final_slash_normalization(script, tmpdir):
""" """
Test that presence or absence of final slash in VCS URL is normalized. Test that presence or absence of final slash in VCS URL is normalized.
""" """
result = script.pip('install', '-e', result = script.pip('install', '-e',
'%s/#egg=ScriptTest' % '%s/#egg=ScriptTest' %
local_checkout('hg+https://bitbucket.org/ianb/scripttest'), local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
expect_error=True) expect_error=True)
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
def test_install_editable_from_bazaar(script): def test_install_editable_from_bazaar(script, tmpdir):
""" """
Test checking out from Bazaar. Test checking out from Bazaar.
""" """
result = script.pip('install', '-e', result = script.pip('install', '-e',
'%s/@174#egg=django-wikiapp' % '%s/@174#egg=django-wikiapp' %
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'), local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
expect_error=True) expect_error=True)
result.assert_installed('django-wikiapp', with_files=['.bzr']) result.assert_installed('django-wikiapp', with_files=['.bzr'])
def test_vcs_url_urlquote_normalization(script): def test_vcs_url_urlquote_normalization(script, tmpdir):
""" """
Test that urlquoted characters are normalized for repo URL comparison. Test that urlquoted characters are normalized for repo URL comparison.
""" """
result = script.pip('install', '-e', result = script.pip('install', '-e',
'%s/#egg=django-wikiapp' % '%s/#egg=django-wikiapp' %
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'), local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
expect_error=True) expect_error=True)
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
...@@ -295,7 +295,7 @@ def test_install_with_hacked_egg_info(script): ...@@ -295,7 +295,7 @@ def test_install_with_hacked_egg_info(script):
assert 'Successfully installed hackedegginfo\n' in result.stdout assert 'Successfully installed hackedegginfo\n' in result.stdout
def test_install_using_install_option_and_editable(script): def test_install_using_install_option_and_editable(script, tmpdir):
""" """
Test installing a tool using -e and --install-option Test installing a tool using -e and --install-option
""" """
...@@ -303,20 +303,20 @@ def test_install_using_install_option_and_editable(script): ...@@ -303,20 +303,20 @@ def test_install_using_install_option_and_editable(script):
script.scratch_path.join(folder).mkdir() script.scratch_path.join(folder).mkdir()
url = 'git+git://github.com/pypa/virtualenv' url = 'git+git://github.com/pypa/virtualenv'
result = script.pip('install', '-e', '%s#egg=virtualenv' % result = script.pip('install', '-e', '%s#egg=virtualenv' %
local_checkout(url), local_checkout(url, tmpdir.join("cache")),
'--install-option=--script-dir=%s' % folder) '--install-option=--script-dir=%s' % folder)
virtualenv_bin = script.venv/'src'/'virtualenv'/folder/'virtualenv'+script.exe virtualenv_bin = script.venv/'src'/'virtualenv'/folder/'virtualenv'+script.exe
assert virtualenv_bin in result.files_created assert virtualenv_bin in result.files_created
def test_install_global_option_using_editable(script): def test_install_global_option_using_editable(script, tmpdir):
""" """
Test using global distutils options, but in an editable installation Test using global distutils options, but in an editable installation
""" """
url = 'hg+http://bitbucket.org/runeh/anyjson' url = 'hg+http://bitbucket.org/runeh/anyjson'
result = script.pip('install', '--global-option=--version', result = script.pip('install', '--global-option=--version',
'-e', '%s@0.2.5#egg=anyjson' % '-e', '%s@0.2.5#egg=anyjson' %
local_checkout(url)) local_checkout(url, tmpdir.join("cache")))
assert '0.2.5\n' in result.stdout assert '0.2.5\n' in result.stdout
......
...@@ -29,7 +29,7 @@ def test_no_clean_option_blocks_cleaning_after_install(script): ...@@ -29,7 +29,7 @@ def test_no_clean_option_blocks_cleaning_after_install(script):
assert exists(build), "build/simple should still exist %s" % str(result) assert exists(build), "build/simple should still exist %s" % str(result)
def test_cleanup_after_install_editable_from_hg(script): def test_cleanup_after_install_editable_from_hg(script, tmpdir):
""" """
Test clean up after cloning from Mercurial. Test clean up after cloning from Mercurial.
...@@ -37,7 +37,7 @@ def test_cleanup_after_install_editable_from_hg(script): ...@@ -37,7 +37,7 @@ def test_cleanup_after_install_editable_from_hg(script):
script.pip('install', script.pip('install',
'-e', '-e',
'%s#egg=ScriptTest' % '%s#egg=ScriptTest' %
local_checkout('hg+https://bitbucket.org/ianb/scripttest'), local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
expect_error=True) expect_error=True)
build = script.venv_path/'build' build = script.venv_path/'build'
src = script.venv_path/'src' src = script.venv_path/'src'
......
...@@ -3,7 +3,7 @@ import textwrap ...@@ -3,7 +3,7 @@ import textwrap
from pip.backwardcompat import urllib from pip.backwardcompat import urllib
from tests.lib import pyversion, tests_data, path_to_url from tests.lib import pyversion, tests_data, path_to_url, packages
def test_find_links_relative_path(script): def test_find_links_relative_path(script):
......
...@@ -59,7 +59,7 @@ def test_relative_requirements_file(script): ...@@ -59,7 +59,7 @@ def test_relative_requirements_file(script):
assert (script.site_packages/'fspkg') in result.files_created, str(result.stdout) assert (script.site_packages/'fspkg') in result.files_created, str(result.stdout)
def test_multiple_requirements_files(script): def test_multiple_requirements_files(script, tmpdir):
""" """
Test installing from multiple nested requirements files. Test installing from multiple nested requirements files.
...@@ -67,7 +67,7 @@ def test_multiple_requirements_files(script): ...@@ -67,7 +67,7 @@ def test_multiple_requirements_files(script):
other_lib_name, other_lib_version = 'anyjson', '0.3' other_lib_name, other_lib_version = 'anyjson', '0.3'
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\ script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
-e %s@10#egg=INITools-dev -e %s@10#egg=INITools-dev
-r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), -r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")),
other_lib_name))) other_lib_name)))
script.scratch_path.join("%s-req.txt" % other_lib_name).write(textwrap.dedent("""\ script.scratch_path.join("%s-req.txt" % other_lib_name).write(textwrap.dedent("""\
%s<=%s %s<=%s
......
...@@ -183,10 +183,10 @@ def test_install_with_ignoreinstalled_requested(script): ...@@ -183,10 +183,10 @@ def test_install_with_ignoreinstalled_requested(script):
assert script.site_packages/'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created assert script.site_packages/'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created
def test_upgrade_vcs_req_with_no_dists_found(script): def test_upgrade_vcs_req_with_no_dists_found(script, tmpdir):
"""It can upgrade a VCS requirement that has no distributions otherwise.""" """It can upgrade a VCS requirement that has no distributions otherwise."""
req = "%s#egg=pip-test-package" % local_checkout( req = "%s#egg=pip-test-package" % local_checkout(
"git+http://github.com/pypa/pip-test-package.git") "git+http://github.com/pypa/pip-test-package.git", tmpdir.join("cache"))
script.pip("install", req) script.pip("install", req)
result = script.pip("install", "-U", req) result = script.pip("install", "-U", req)
assert not result.returncode assert not result.returncode
......
...@@ -52,14 +52,14 @@ class Tests_UserSite: ...@@ -52,14 +52,14 @@ class Tests_UserSite:
assert 'INITools'== project_name, "'%s' should be 'INITools'" %project_name assert 'INITools'== project_name, "'%s' should be 'INITools'" %project_name
def test_install_subversion_usersite_editable_with_distribute(self, script, virtualenv): def test_install_subversion_usersite_editable_with_distribute(self, script, virtualenv, tmpdir):
""" """
Test installing current directory ('.') into usersite after installing distribute Test installing current directory ('.') into usersite after installing distribute
""" """
virtualenv.system_site_packages = True virtualenv.system_site_packages = True
result = script.pip('install', '--user', '-e', result = script.pip('install', '--user', '-e',
'%s#egg=initools-dev' % '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
result.assert_installed('INITools', use_user_site=True) result.assert_installed('INITools', use_user_site=True)
......
...@@ -2,13 +2,13 @@ from tests.lib import _create_test_package, _change_test_package_version ...@@ -2,13 +2,13 @@ from tests.lib import _create_test_package, _change_test_package_version
from tests.lib.local_repos import local_checkout from tests.lib.local_repos import local_checkout
def test_install_editable_from_git_with_https(script): def test_install_editable_from_git_with_https(script, tmpdir):
""" """
Test cloning from Git with https. Test cloning from Git with https.
""" """
result = script.pip('install', '-e', result = script.pip('install', '-e',
'%s#egg=pip-test-package' % '%s#egg=pip-test-package' %
local_checkout('git+https://github.com/pypa/pip-test-package.git'), local_checkout('git+https://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
expect_error=True) expect_error=True)
result.assert_installed('pip-test-package', with_files=['.git']) result.assert_installed('pip-test-package', with_files=['.git'])
...@@ -49,59 +49,60 @@ def test_git_with_tag_name_as_revision(script): ...@@ -49,59 +49,60 @@ def test_git_with_tag_name_as_revision(script):
assert '0.1' in version.stdout assert '0.1' in version.stdout
def test_git_with_tag_name_and_update(script): def test_git_with_tag_name_and_update(script, tmpdir):
""" """
Test cloning a git repository and updating to a different version. Test cloning a git repository and updating to a different version.
""" """
result = script.pip('install', '-e', '%s#egg=pip-test-package' % result = script.pip('install', '-e', '%s#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git'), local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
expect_error=True) expect_error=True)
result.assert_installed('pip-test-package', with_files=['.git']) result.assert_installed('pip-test-package', with_files=['.git'])
result = script.pip('install', '--global-option=--version', '-e', result = script.pip('install', '--global-option=--version', '-e',
'%s@0.1.2#egg=pip-test-package' % '%s@0.1.2#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git'), local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
expect_error=True) expect_error=True)
assert '0.1.2' in result.stdout assert '0.1.2' in result.stdout
def test_git_branch_should_not_be_changed(script): def test_git_branch_should_not_be_changed(script, tmpdir):
""" """
Editable installations should not change branch Editable installations should not change branch
related to issue #32 and #161 related to issue #32 and #161
""" """
script.pip('install', '-e', '%s#egg=pip-test-package' % script.pip('install', '-e', '%s#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git'), local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
expect_error=True) expect_error=True)
source_dir = script.venv_path/'src'/'pip-test-package' source_dir = script.venv_path/'src'/'pip-test-package'
result = script.run('git', 'branch', cwd=source_dir) result = script.run('git', 'branch', cwd=source_dir)
assert '* master' in result.stdout, result.stdout assert '* master' in result.stdout, result.stdout
def test_git_with_non_editable_unpacking(script): def test_git_with_non_editable_unpacking(script, tmpdir):
""" """
Test cloning a git repository from a non-editable URL with a given tag. Test cloning a git repository from a non-editable URL with a given tag.
""" """
result = script.pip('install', '--global-option=--version', local_checkout( result = script.pip('install', '--global-option=--version', local_checkout(
'git+http://github.com/pypa/pip-test-package.git@0.1.2#egg=pip-test-package' 'git+http://github.com/pypa/pip-test-package.git@0.1.2#egg=pip-test-package',
tmpdir.join("cache")
), expect_error=True) ), expect_error=True)
assert '0.1.2' in result.stdout assert '0.1.2' in result.stdout
def test_git_with_editable_where_egg_contains_dev_string(script): def test_git_with_editable_where_egg_contains_dev_string(script, tmpdir):
""" """
Test cloning a git repository from an editable url which contains "dev" string Test cloning a git repository from an editable url which contains "dev" string
""" """
result = script.pip('install', '-e', '%s#egg=django-devserver' % result = script.pip('install', '-e', '%s#egg=django-devserver' %
local_checkout('git+git://github.com/dcramer/django-devserver.git')) local_checkout('git+git://github.com/dcramer/django-devserver.git', tmpdir.join("cache")))
result.assert_installed('django-devserver', with_files=['.git']) result.assert_installed('django-devserver', with_files=['.git'])
def test_git_with_non_editable_where_egg_contains_dev_string(script): def test_git_with_non_editable_where_egg_contains_dev_string(script, tmpdir):
""" """
Test cloning a git repository from a non-editable url which contains "dev" string Test cloning a git repository from a non-editable url which contains "dev" string
""" """
result = script.pip('install', '%s#egg=django-devserver' % result = script.pip('install', '%s#egg=django-devserver' %
local_checkout('git+git://github.com/dcramer/django-devserver.git')) local_checkout('git+git://github.com/dcramer/django-devserver.git', tmpdir.join("cache")))
devserver_folder = script.site_packages/'devserver' devserver_folder = script.site_packages/'devserver'
assert devserver_folder in result.files_created, str(result) assert devserver_folder in result.files_created, str(result)
......
...@@ -113,40 +113,42 @@ def test_uninstall_easy_installed_console_scripts(script): ...@@ -113,40 +113,42 @@ def test_uninstall_easy_installed_console_scripts(script):
assert_all_changes(result, result2, [script.venv/'build', 'cache']) assert_all_changes(result, result2, [script.venv/'build', 'cache'])
def test_uninstall_editable_from_svn(script): def test_uninstall_editable_from_svn(script, tmpdir):
""" """
Test uninstalling an editable installation from svn. Test uninstalling an editable installation from svn.
""" """
result = script.pip('install', '-e', '%s#egg=initools-dev' % result = script.pip('install', '-e', '%s#egg=initools-dev' %
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
result.assert_installed('INITools') result.assert_installed('INITools')
result2 = script.pip('uninstall', '-y', 'initools') result2 = script.pip('uninstall', '-y', 'initools')
assert (script.venv/'src'/'initools' in result2.files_after), 'oh noes, pip deleted my sources!' assert (script.venv/'src'/'initools' in result2.files_after), 'oh noes, pip deleted my sources!'
assert_all_changes(result, result2, [script.venv/'src', script.venv/'build']) assert_all_changes(result, result2, [script.venv/'src', script.venv/'build'])
def test_uninstall_editable_with_source_outside_venv(script): def test_uninstall_editable_with_source_outside_venv(script, tmpdir):
""" """
Test uninstalling editable install from existing source outside the venv. Test uninstalling editable install from existing source outside the venv.
""" """
cache_dir = tmpdir.join("cache")
try: try:
temp = mkdtemp() temp = mkdtemp()
tmpdir = join(temp, 'virtualenv') tmpdir = join(temp, 'virtualenv')
_test_uninstall_editable_with_source_outside_venv(script, tmpdir) _test_uninstall_editable_with_source_outside_venv(script, tmpdir, cache_dir)
finally: finally:
rmtree(temp) rmtree(temp)
def _test_uninstall_editable_with_source_outside_venv(script, tmpdir): def _test_uninstall_editable_with_source_outside_venv(script, tmpdir, cache_dir):
result = script.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv'), tmpdir) result = script.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv', cache_dir), tmpdir)
result2 = script.pip('install', '-e', tmpdir) result2 = script.pip('install', '-e', tmpdir)
assert (join(script.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys()) assert (join(script.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys())
result3 = script.pip('uninstall', '-y', 'virtualenv', expect_error=True) result3 = script.pip('uninstall', '-y', 'virtualenv', expect_error=True)
assert_all_changes(result, result3, [script.venv/'build']) assert_all_changes(result, result3, [script.venv/'build'])
def test_uninstall_from_reqs_file(script): def test_uninstall_from_reqs_file(script, tmpdir):
""" """
Test uninstall from a requirements file. Test uninstall from a requirements file.
...@@ -155,7 +157,7 @@ def test_uninstall_from_reqs_file(script): ...@@ -155,7 +157,7 @@ def test_uninstall_from_reqs_file(script):
-e %s#egg=initools-dev -e %s#egg=initools-dev
# and something else to test out: # and something else to test out:
PyLogo<0.4 PyLogo<0.4
""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
result = script.pip('install', '-r', 'test-req.txt') result = script.pip('install', '-r', 'test-req.txt')
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""\ script.scratch_path.join("test-req.txt").write(textwrap.dedent("""\
# -f, -i, and --extra-index-url should all be ignored by uninstall # -f, -i, and --extra-index-url should all be ignored by uninstall
...@@ -166,7 +168,7 @@ def test_uninstall_from_reqs_file(script): ...@@ -166,7 +168,7 @@ def test_uninstall_from_reqs_file(script):
-e %s#egg=initools-dev -e %s#egg=initools-dev
# and something else to test out: # and something else to test out:
PyLogo<0.4 PyLogo<0.4
""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
result2 = script.pip('uninstall', '-r', 'test-req.txt', '-y') result2 = script.pip('uninstall', '-r', 'test-req.txt', '-y')
assert_all_changes( assert_all_changes(
result, result2, [script.venv/'build', script.venv/'src', script.scratch/'test-req.txt']) result, result2, [script.venv/'build', script.venv/'src', script.scratch/'test-req.txt'])
......
...@@ -13,16 +13,13 @@ else: ...@@ -13,16 +13,13 @@ else:
subprocess_call = subprocess.call subprocess_call = subprocess.call
CACHE_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests_cache') def _create_initools_repository(directory):
subprocess_call('svnadmin create INITools'.split(), cwd=directory)
def _create_initools_repository(): def _dump_initools_repository(directory):
subprocess_call('svnadmin create INITools'.split(), cwd=_get_vcs_folder())
def _dump_initools_repository():
filename, _ = urlretrieve('http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/INITools_modified.dump') filename, _ = urlretrieve('http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/INITools_modified.dump')
initools_folder = os.path.join(_get_vcs_folder(), 'INITools') initools_folder = os.path.join(directory, 'INITools')
devnull = open(os.devnull, 'w') devnull = open(os.devnull, 'w')
dump = open(filename) dump = open(filename)
subprocess_call(['svnadmin', 'load', initools_folder], stdin=dump, stdout=devnull) subprocess_call(['svnadmin', 'load', initools_folder], stdin=dump, stdout=devnull)
...@@ -31,21 +28,13 @@ def _dump_initools_repository(): ...@@ -31,21 +28,13 @@ def _dump_initools_repository():
os.remove(filename) os.remove(filename)
def _create_svn_repository_for_initools(): def _create_svn_repository_for_initools(directory):
tests_cache = _get_vcs_folder() if not os.path.exists(os.path.join(directory, 'INITools')):
if not os.path.exists(os.path.join(tests_cache, 'INITools')): _create_initools_repository(directory)
_create_initools_repository() _dump_initools_repository(directory)
_dump_initools_repository()
def _get_vcs_folder():
if not os.path.exists(CACHE_PATH):
os.mkdir(CACHE_PATH)
return CACHE_PATH
def _get_vcs_and_checkout_url(remote_repository, directory):
def _get_vcs_and_checkout_url(remote_repository):
tests_cache = _get_vcs_folder()
vcs_classes = {'svn': subversion.Subversion, vcs_classes = {'svn': subversion.Subversion,
'git': git.Git, 'git': git.Git,
'bzr': bazaar.Bazaar, 'bzr': bazaar.Bazaar,
...@@ -62,17 +51,21 @@ def _get_vcs_and_checkout_url(remote_repository): ...@@ -62,17 +51,21 @@ def _get_vcs_and_checkout_url(remote_repository):
else: else:
repository_name = os.path.basename(remote_repository) repository_name = os.path.basename(remote_repository)
destination_path = os.path.join(tests_cache, repository_name) destination_path = os.path.join(directory, repository_name)
if not os.path.exists(destination_path): if not os.path.exists(destination_path):
vcs_class(remote_repository).obtain(destination_path) vcs_class(remote_repository).obtain(destination_path)
return '%s+%s' % (vcs, path_to_url('/'.join([tests_cache, repository_name, branch]))) return '%s+%s' % (vcs, path_to_url('/'.join([directory, repository_name, branch])))
def local_checkout(remote_repo, directory):
if not os.path.exists(directory):
os.mkdir(directory)
#os.makedirs(directory)
def local_checkout(remote_repo):
if remote_repo.startswith('svn'): if remote_repo.startswith('svn'):
_create_svn_repository_for_initools() _create_svn_repository_for_initools(directory)
return _get_vcs_and_checkout_url(remote_repo) return _get_vcs_and_checkout_url(remote_repo, directory)
def local_repo(remote_repo): def local_repo(remote_repo, directory):
return local_checkout(remote_repo).split('+', 1)[1] return local_checkout(remote_repo, directory).split('+', 1)[1]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册