mirror of https://github.com/pypa/pip
Replace explicit calls to reset_env() with the script fixture
This commit is contained in:
parent
f70b2a187c
commit
0c42245f21
|
@ -2,19 +2,18 @@ import zipfile
|
|||
import textwrap
|
||||
from os.path import abspath, exists, join
|
||||
from pip.download import path_to_url2
|
||||
from tests.lib import tests_data, reset_env
|
||||
from tests.lib import tests_data
|
||||
from tests.lib.path import Path
|
||||
from tests.lib.local_repos import local_checkout
|
||||
|
||||
|
||||
def test_create_bundle():
|
||||
def test_create_bundle(script):
|
||||
"""
|
||||
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).
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
fspkg = path_to_url2(Path(tests_data)/'packages'/'FSPkg')
|
||||
script.pip('install', '-e', fspkg)
|
||||
pkg_lines = textwrap.dedent('''\
|
||||
|
@ -33,12 +32,11 @@ def test_create_bundle():
|
|||
assert 'build/pip/' in files
|
||||
|
||||
|
||||
def test_cleanup_after_create_bundle():
|
||||
def test_cleanup_after_create_bundle(script):
|
||||
"""
|
||||
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
# Install an editable to create a src/ dir.
|
||||
args = ['install']
|
||||
args.extend(['-e',
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import os
|
||||
from tests.lib import reset_env
|
||||
|
||||
|
||||
def test_completion_for_bash():
|
||||
def test_completion_for_bash(script):
|
||||
"""
|
||||
Test getting completion for bash shell
|
||||
"""
|
||||
script = reset_env()
|
||||
bash_completion = """\
|
||||
_pip_completion()
|
||||
{
|
||||
|
@ -20,11 +18,10 @@ complete -o default -F _pip_completion pip"""
|
|||
assert bash_completion in result.stdout, 'bash completion is wrong'
|
||||
|
||||
|
||||
def test_completion_for_zsh():
|
||||
def test_completion_for_zsh(script):
|
||||
"""
|
||||
Test getting completion for zsh shell
|
||||
"""
|
||||
script = reset_env()
|
||||
zsh_completion = """\
|
||||
function _pip_completion {
|
||||
local words cword
|
||||
|
@ -40,32 +37,29 @@ compctl -K _pip_completion pip"""
|
|||
assert zsh_completion in result.stdout, 'zsh completion is wrong'
|
||||
|
||||
|
||||
def test_completion_for_unknown_shell():
|
||||
def test_completion_for_unknown_shell(script):
|
||||
"""
|
||||
Test getting completion for an unknown shell
|
||||
"""
|
||||
script = reset_env()
|
||||
error_msg = 'no such option: --myfooshell'
|
||||
result = script.pip('completion', '--myfooshell', expect_error=True)
|
||||
assert error_msg in result.stderr, 'tests for an unknown shell failed'
|
||||
|
||||
|
||||
def test_completion_alone():
|
||||
def test_completion_alone(script):
|
||||
"""
|
||||
Test getting completion for none shell, just pip completion
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('completion', expect_error=True)
|
||||
assert 'ERROR: You must pass --bash or --zsh' in result.stderr, \
|
||||
'completion alone failed -- ' + result.stderr
|
||||
|
||||
|
||||
def setup_completion(words, cword):
|
||||
environ = os.environ.copy()
|
||||
script = reset_env(environ)
|
||||
environ['PIP_AUTO_COMPLETE'] = '1'
|
||||
environ['COMP_WORDS'] = words
|
||||
environ['COMP_CWORD'] = cword
|
||||
def setup_completion(script, words, cword):
|
||||
script.environ = os.environ.copy()
|
||||
script.environ['PIP_AUTO_COMPLETE'] = '1'
|
||||
script.environ['COMP_WORDS'] = words
|
||||
script.environ['COMP_CWORD'] = cword
|
||||
|
||||
# expect_error is True because autocomplete exists with 1 status code
|
||||
result = script.run('python', '-c', 'import pip;pip.autocomplete()',
|
||||
|
@ -74,31 +68,31 @@ def setup_completion(words, cword):
|
|||
return result, script
|
||||
|
||||
|
||||
def test_completion_for_un_snippet():
|
||||
def test_completion_for_un_snippet(script):
|
||||
"""
|
||||
Test getting completion for ``un`` should return
|
||||
uninstall and unzip
|
||||
"""
|
||||
|
||||
res, env = setup_completion('pip un', '1')
|
||||
res, env = setup_completion(script, 'pip un', '1')
|
||||
assert res.stdout.strip().split() == ['uninstall', 'unzip'], res.stdout
|
||||
|
||||
|
||||
def test_completion_for_default_parameters():
|
||||
def test_completion_for_default_parameters(script):
|
||||
"""
|
||||
Test getting completion for ``--`` should contain --help
|
||||
"""
|
||||
|
||||
res, env = setup_completion('pip --', '1')
|
||||
res, env = setup_completion(script, 'pip --', '1')
|
||||
assert '--help' in res.stdout,\
|
||||
"autocomplete function could not complete ``--``"
|
||||
|
||||
|
||||
def test_completion_option_for_command():
|
||||
def test_completion_option_for_command(script):
|
||||
"""
|
||||
Test getting completion for ``--`` in command (eg. pip search --)
|
||||
"""
|
||||
|
||||
res, env = setup_completion('pip search --', '2')
|
||||
res, env = setup_completion(script, 'pip search --', '2')
|
||||
assert '--help' in res.stdout,\
|
||||
"autocomplete function could not complete ``--``"
|
||||
|
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import re
|
||||
import textwrap
|
||||
from doctest import OutputChecker, ELLIPSIS
|
||||
from tests.lib import reset_env
|
||||
|
||||
from tests.lib.local_repos import local_checkout, local_repo
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ def _check_output(result, expected):
|
|||
assert checker.check_output(expected, actual, ELLIPSIS), banner('EXPECTED')+expected+banner('ACTUAL')+actual+banner(6*'=')
|
||||
|
||||
|
||||
def test_freeze_basic():
|
||||
def test_freeze_basic(script):
|
||||
"""
|
||||
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
|
||||
|
@ -42,7 +42,6 @@ def test_freeze_basic():
|
|||
currently it is not).
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
|
||||
simple==2.0
|
||||
# and something else to test out:
|
||||
|
@ -59,14 +58,13 @@ def test_freeze_basic():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_svn():
|
||||
def test_freeze_svn(script):
|
||||
"""Test freezing a svn checkout"""
|
||||
|
||||
checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')
|
||||
#svn internally stores windows drives as uppercase; we'll match that.
|
||||
checkout_path = checkout_path.replace('c:', 'C:')
|
||||
|
||||
script = reset_env()
|
||||
result = script.run('svn', 'co', '-r10',
|
||||
local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
|
||||
'initools-trunk')
|
||||
|
@ -81,12 +79,11 @@ def test_freeze_svn():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_git_clone():
|
||||
def test_freeze_git_clone(script):
|
||||
"""
|
||||
Test freezing a Git clone.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git'), 'pip-test-package')
|
||||
result = script.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
|
||||
cwd=script.scratch_path / 'pip-test-package', expect_stderr=True)
|
||||
|
@ -112,12 +109,11 @@ def test_freeze_git_clone():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_mercurial_clone():
|
||||
def test_freeze_mercurial_clone(script):
|
||||
"""
|
||||
Test freezing a Mercurial clone.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.run('hg', 'clone',
|
||||
'-r', 'c9963c111e7c',
|
||||
local_repo('hg+http://bitbucket.org/pypa/pip-test-package'),
|
||||
|
@ -144,7 +140,7 @@ def test_freeze_mercurial_clone():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_bazaar_clone():
|
||||
def test_freeze_bazaar_clone(script):
|
||||
"""
|
||||
Test freezing a Bazaar clone.
|
||||
|
||||
|
@ -154,7 +150,6 @@ def test_freeze_bazaar_clone():
|
|||
#bzr internally stores windows drives as uppercase; we'll match that.
|
||||
checkout_pathC = checkout_path.replace('c:', 'C:')
|
||||
|
||||
script = reset_env()
|
||||
result = script.run('bzr', 'checkout', '-r', '174',
|
||||
local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
||||
'django-wikiapp')
|
||||
|
@ -180,12 +175,11 @@ def test_freeze_bazaar_clone():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_with_local_option():
|
||||
def test_freeze_with_local_option(script):
|
||||
"""
|
||||
Test that wsgiref (from global site-packages) is reported normally, but not with --local.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'initools==0.2')
|
||||
result = script.pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent("""\
|
||||
|
@ -211,12 +205,11 @@ def test_freeze_with_local_option():
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
def test_freeze_with_requirement_option():
|
||||
def test_freeze_with_requirement_option(script):
|
||||
"""
|
||||
Test that new requirements are created correctly with --requirement hints
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
ignores = textwrap.dedent("""\
|
||||
# Unchanged requirements below this line
|
||||
-r ignore.txt
|
||||
|
|
|
@ -6,7 +6,6 @@ from pip.basecommand import ERROR, SUCCESS
|
|||
from pip.commands.help import HelpCommand
|
||||
from pip.commands import commands
|
||||
from mock import Mock
|
||||
from tests.lib import reset_env
|
||||
|
||||
|
||||
def test_run_method_should_return_sucess_when_finds_command_name():
|
||||
|
@ -43,38 +42,34 @@ def test_run_method_should_raise_command_error_when_command_does_not_exist():
|
|||
help_cmd.run(options_mock, args)
|
||||
|
||||
|
||||
def test_help_command_should_exit_status_ok_when_command_exists():
|
||||
def test_help_command_should_exit_status_ok_when_command_exists(script):
|
||||
"""
|
||||
Test `help` command for existing command
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('help', 'freeze')
|
||||
assert result.returncode == SUCCESS
|
||||
|
||||
|
||||
def test_help_command_should_exit_status_ok_when_no_command_is_specified():
|
||||
def test_help_command_should_exit_status_ok_when_no_cmd_is_specified(script):
|
||||
"""
|
||||
Test `help` command for no command
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('help')
|
||||
assert result.returncode == SUCCESS
|
||||
|
||||
|
||||
def test_help_command_should_exit_status_error_when_command_does_not_exist():
|
||||
def test_help_command_should_exit_status_error_when_cmd_does_not_exist(script):
|
||||
"""
|
||||
Test `help` command for non-existing command
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('help', 'mycommand', expect_error=True)
|
||||
assert result.returncode == ERROR
|
||||
|
||||
def test_help_commands_equally_functional():
|
||||
|
||||
def test_help_commands_equally_functional(script):
|
||||
"""
|
||||
Test if `pip help` and 'pip --help' behave the same way.
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
results = list(map(script.pip, ('help', '--help')))
|
||||
results.append(script.pip())
|
||||
|
||||
|
|
|
@ -7,17 +7,15 @@ from os.path import abspath, join, curdir, pardir
|
|||
import pytest
|
||||
|
||||
from pip.util import rmtree
|
||||
from tests.lib import tests_data, reset_env, pyversion, find_links
|
||||
from tests.lib import tests_data, pyversion, find_links
|
||||
from tests.lib.local_repos import local_checkout
|
||||
from tests.lib.path import Path
|
||||
|
||||
|
||||
def test_pip_second_command_line_interface_works():
|
||||
def test_pip_second_command_line_interface_works(script):
|
||||
"""
|
||||
Check if ``pip<PYVERSION>`` commands behaves equally
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
args = ['pip%s' % pyversion]
|
||||
args.extend(['install', 'INITools==0.2'])
|
||||
result = script.run(*args)
|
||||
|
@ -27,11 +25,10 @@ def test_pip_second_command_line_interface_works():
|
|||
assert initools_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_from_pypi():
|
||||
def test_install_from_pypi(script):
|
||||
"""
|
||||
Test installing a package from PyPI.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-vvv', 'INITools==0.2')
|
||||
egg_info_folder = script.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
|
||||
initools_folder = script.site_packages / 'initools'
|
||||
|
@ -39,22 +36,20 @@ def test_install_from_pypi():
|
|||
assert initools_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_editable_install():
|
||||
def test_editable_install(script):
|
||||
"""
|
||||
Test editable installation.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e', 'INITools==0.2', expect_error=True)
|
||||
assert "INITools==0.2 should either by a path to a local project or a VCS url" in result.stdout
|
||||
assert len(result.files_created) == 1, result.files_created
|
||||
assert not result.files_updated, result.files_updated
|
||||
|
||||
|
||||
def test_install_editable_from_svn():
|
||||
def test_install_editable_from_svn(script):
|
||||
"""
|
||||
Test checking out from svn.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install',
|
||||
'-e',
|
||||
'%s#egg=initools-dev' %
|
||||
|
@ -62,11 +57,10 @@ def test_install_editable_from_svn():
|
|||
result.assert_installed('INITools', with_files=['.svn'])
|
||||
|
||||
|
||||
def test_download_editable_to_custom_path():
|
||||
def test_download_editable_to_custom_path(script):
|
||||
"""
|
||||
Test downloading an editable using a relative custom src folder.
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("customdl").mkdir()
|
||||
result = script.pip('install',
|
||||
'-e',
|
||||
|
@ -86,12 +80,10 @@ def test_download_editable_to_custom_path():
|
|||
assert customdl_files_created
|
||||
|
||||
|
||||
def test_editable_no_install_followed_by_no_download():
|
||||
def test_editable_no_install_followed_by_no_download(script):
|
||||
"""
|
||||
Test installing an editable in two steps (first with --no-install, then with --no-download).
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
result = script.pip('install',
|
||||
'-e',
|
||||
'%s#egg=initools-dev' %
|
||||
|
@ -107,12 +99,10 @@ def test_editable_no_install_followed_by_no_download():
|
|||
result.assert_installed('INITools', without_files=[curdir, '.svn'])
|
||||
|
||||
|
||||
def test_no_install_followed_by_no_download():
|
||||
def test_no_install_followed_by_no_download(script):
|
||||
"""
|
||||
Test installing in two steps (first with --no-install, then with --no-download).
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
egg_info_folder = script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion
|
||||
initools_folder = script.site_packages/'initools'
|
||||
build_dir = script.venv/'build'/'INITools'
|
||||
|
@ -130,21 +120,19 @@ def test_no_install_followed_by_no_download():
|
|||
assert build_dir/'INITools.egg-info' not in result2.files_created
|
||||
|
||||
|
||||
def test_bad_install_with_no_download():
|
||||
def test_bad_install_with_no_download(script):
|
||||
"""
|
||||
Test that --no-download behaves sensibly if the package source can't be found.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.2', '--no-download', expect_error=True)
|
||||
assert "perhaps --no-download was used without first running "\
|
||||
"an equivalent install with --no-install?" in result.stdout
|
||||
|
||||
|
||||
def test_install_dev_version_from_pypi():
|
||||
def test_install_dev_version_from_pypi(script):
|
||||
"""
|
||||
Test using package==dev.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==dev',
|
||||
'--allow-external', 'INITools',
|
||||
'--allow-insecure', 'INITools',
|
||||
|
@ -152,11 +140,10 @@ def test_install_dev_version_from_pypi():
|
|||
assert (script.site_packages / 'initools') in result.files_created, str(result.stdout)
|
||||
|
||||
|
||||
def test_install_editable_from_git():
|
||||
def test_install_editable_from_git(script):
|
||||
"""
|
||||
Test cloning from Git.
|
||||
"""
|
||||
script = reset_env()
|
||||
args = ['install']
|
||||
args.extend(['-e',
|
||||
'%s#egg=pip-test-package' %
|
||||
|
@ -165,11 +152,10 @@ def test_install_editable_from_git():
|
|||
result.assert_installed('pip-test-package', with_files=['.git'])
|
||||
|
||||
|
||||
def test_install_editable_from_hg():
|
||||
def test_install_editable_from_hg(script):
|
||||
"""
|
||||
Test cloning from Mercurial.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e',
|
||||
'%s#egg=ScriptTest' %
|
||||
local_checkout('hg+https://bitbucket.org/ianb/scripttest'),
|
||||
|
@ -177,11 +163,10 @@ def test_install_editable_from_hg():
|
|||
result.assert_installed('ScriptTest', with_files=['.hg'])
|
||||
|
||||
|
||||
def test_vcs_url_final_slash_normalization():
|
||||
def test_vcs_url_final_slash_normalization(script):
|
||||
"""
|
||||
Test that presence or absence of final slash in VCS URL is normalized.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e',
|
||||
'%s/#egg=ScriptTest' %
|
||||
local_checkout('hg+https://bitbucket.org/ianb/scripttest'),
|
||||
|
@ -189,11 +174,10 @@ def test_vcs_url_final_slash_normalization():
|
|||
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
||||
|
||||
def test_install_editable_from_bazaar():
|
||||
def test_install_editable_from_bazaar(script):
|
||||
"""
|
||||
Test checking out from Bazaar.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e',
|
||||
'%s/@174#egg=django-wikiapp' %
|
||||
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
||||
|
@ -201,11 +185,10 @@ def test_install_editable_from_bazaar():
|
|||
result.assert_installed('django-wikiapp', with_files=['.bzr'])
|
||||
|
||||
|
||||
def test_vcs_url_urlquote_normalization():
|
||||
def test_vcs_url_urlquote_normalization(script):
|
||||
"""
|
||||
Test that urlquoted characters are normalized for repo URL comparison.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e',
|
||||
'%s/#egg=django-wikiapp' %
|
||||
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
||||
|
@ -213,11 +196,10 @@ def test_vcs_url_urlquote_normalization():
|
|||
assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
|
||||
|
||||
|
||||
def test_install_from_local_directory():
|
||||
def test_install_from_local_directory(script):
|
||||
"""
|
||||
Test installing from a local directory.
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
result = script.pip('install', to_install, expect_error=False)
|
||||
fspkg_folder = script.site_packages/'fspkg'
|
||||
|
@ -226,33 +208,30 @@ def test_install_from_local_directory():
|
|||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_from_local_directory_with_no_setup_py():
|
||||
def test_install_from_local_directory_with_no_setup_py(script):
|
||||
"""
|
||||
Test installing from a local directory with no 'setup.py'.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', tests_data, expect_error=True)
|
||||
assert len(result.files_created) == 1, result.files_created
|
||||
assert 'pip-log.txt' in result.files_created, result.files_created
|
||||
assert "is not installable. File 'setup.py' not found." in result.stdout
|
||||
|
||||
|
||||
def test_editable_install_from_local_directory_with_no_setup_py():
|
||||
def test_editable_install_from_local_directory_with_no_setup_py(script):
|
||||
"""
|
||||
Test installing from a local directory with no 'setup.py'.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e', tests_data, expect_error=True)
|
||||
assert len(result.files_created) == 1, result.files_created
|
||||
assert 'pip-log.txt' in result.files_created, result.files_created
|
||||
assert "is not installable. File 'setup.py' not found." in result.stdout
|
||||
|
||||
|
||||
def test_install_as_egg():
|
||||
def test_install_as_egg(script):
|
||||
"""
|
||||
Test installing as egg, instead of flat install.
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
result = script.pip('install', to_install, '--egg', expect_error=False)
|
||||
fspkg_folder = script.site_packages/'fspkg'
|
||||
|
@ -262,11 +241,10 @@ def test_install_as_egg():
|
|||
assert join(egg_folder, 'fspkg') in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_curdir():
|
||||
def test_install_curdir(script):
|
||||
"""
|
||||
Test installing current directory ('.').
|
||||
"""
|
||||
script = reset_env()
|
||||
run_from = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
# Python 2.4 Windows balks if this exists already
|
||||
egg_info = join(run_from, "FSPkg.egg-info")
|
||||
|
@ -279,11 +257,10 @@ def test_install_curdir():
|
|||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_pardir():
|
||||
def test_install_pardir(script):
|
||||
"""
|
||||
Test installing parent directory ('..').
|
||||
"""
|
||||
script = reset_env()
|
||||
run_from = abspath(join(tests_data, 'packages', 'FSPkg', 'fspkg'))
|
||||
result = script.pip('install', pardir, cwd=run_from, expect_error=False)
|
||||
fspkg_folder = script.site_packages/'fspkg'
|
||||
|
@ -292,40 +269,36 @@ def test_install_pardir():
|
|||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_global_option():
|
||||
def test_install_global_option(script):
|
||||
"""
|
||||
Test using global distutils options.
|
||||
(In particular those that disable the actual install action)
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '--global-option=--version', "INITools==0.1")
|
||||
assert '0.1\n' in result.stdout
|
||||
|
||||
|
||||
def test_install_with_pax_header():
|
||||
def test_install_with_pax_header(script):
|
||||
"""
|
||||
test installing from a tarball with pax header for python<2.6
|
||||
"""
|
||||
script = reset_env()
|
||||
run_from = abspath(join(tests_data, 'packages'))
|
||||
script.pip('install', 'paxpkg.tar.bz2', cwd=run_from)
|
||||
|
||||
|
||||
def test_install_with_hacked_egg_info():
|
||||
def test_install_with_hacked_egg_info(script):
|
||||
"""
|
||||
test installing a package which defines its own egg_info class
|
||||
"""
|
||||
script = reset_env()
|
||||
run_from = abspath(join(tests_data, 'packages', 'HackedEggInfo'))
|
||||
result = script.pip('install', '.', cwd=run_from)
|
||||
assert 'Successfully installed hackedegginfo\n' in result.stdout
|
||||
|
||||
|
||||
def test_install_using_install_option_and_editable():
|
||||
def test_install_using_install_option_and_editable(script):
|
||||
"""
|
||||
Test installing a tool using -e and --install-option
|
||||
"""
|
||||
script = reset_env()
|
||||
folder = 'script_folder'
|
||||
script.scratch_path.join(folder).mkdir()
|
||||
url = 'git+git://github.com/pypa/virtualenv'
|
||||
|
@ -336,11 +309,10 @@ def test_install_using_install_option_and_editable():
|
|||
assert virtualenv_bin in result.files_created
|
||||
|
||||
|
||||
def test_install_global_option_using_editable():
|
||||
def test_install_global_option_using_editable(script):
|
||||
"""
|
||||
Test using global distutils options, but in an editable installation
|
||||
"""
|
||||
script = reset_env()
|
||||
url = 'hg+http://bitbucket.org/runeh/anyjson'
|
||||
result = script.pip('install', '--global-option=--version',
|
||||
'-e', '%s@0.2.5#egg=anyjson' %
|
||||
|
@ -348,11 +320,10 @@ def test_install_global_option_using_editable():
|
|||
assert '0.2.5\n' in result.stdout
|
||||
|
||||
|
||||
def test_install_package_with_same_name_in_curdir():
|
||||
def test_install_package_with_same_name_in_curdir(script):
|
||||
"""
|
||||
Test installing a package with the same name of a local folder
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("mock==0.6").mkdir()
|
||||
result = script.pip('install', 'mock==0.6')
|
||||
egg_folder = script.site_packages / 'mock-0.6.0-py%s.egg-info' % pyversion
|
||||
|
@ -365,11 +336,10 @@ mock100_setup_py = textwrap.dedent('''\
|
|||
version='100.1')''')
|
||||
|
||||
|
||||
def test_install_folder_using_dot_slash():
|
||||
def test_install_folder_using_dot_slash(script):
|
||||
"""
|
||||
Test installing a folder using pip install ./foldername
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("mock").mkdir()
|
||||
pkg_path = script.scratch_path/'mock'
|
||||
pkg_path.join("setup.py").write(mock100_setup_py)
|
||||
|
@ -378,11 +348,10 @@ def test_install_folder_using_dot_slash():
|
|||
assert egg_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_folder_using_slash_in_the_end():
|
||||
def test_install_folder_using_slash_in_the_end(script):
|
||||
r"""
|
||||
Test installing a folder using pip install foldername/ or foldername\
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("mock").mkdir()
|
||||
pkg_path = script.scratch_path/'mock'
|
||||
pkg_path.join("setup.py").write(mock100_setup_py)
|
||||
|
@ -391,11 +360,10 @@ def test_install_folder_using_slash_in_the_end():
|
|||
assert egg_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_folder_using_relative_path():
|
||||
def test_install_folder_using_relative_path(script):
|
||||
"""
|
||||
Test installing a folder using pip install folder1/folder2
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("initools").mkdir()
|
||||
script.scratch_path.join("initools", "mock").mkdir()
|
||||
pkg_path = script.scratch_path/'initools'/'mock'
|
||||
|
@ -405,11 +373,10 @@ def test_install_folder_using_relative_path():
|
|||
assert egg_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_package_which_contains_dev_in_name():
|
||||
def test_install_package_which_contains_dev_in_name(script):
|
||||
"""
|
||||
Test installing package from pypi which contains 'dev' in name
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'django-devserver==0.0.4')
|
||||
devserver_folder = script.site_packages/'devserver'
|
||||
egg_info_folder = script.site_packages/'django_devserver-0.0.4-py%s.egg-info' % pyversion
|
||||
|
@ -417,21 +384,19 @@ def test_install_package_which_contains_dev_in_name():
|
|||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_package_with_target():
|
||||
def test_install_package_with_target(script):
|
||||
"""
|
||||
Test installing a package using pip install --target
|
||||
"""
|
||||
script = reset_env()
|
||||
target_dir = script.scratch_path/'target'
|
||||
result = script.pip('install', '-t', target_dir, "initools==0.1")
|
||||
assert Path('scratch')/'target'/'initools' in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_package_with_root():
|
||||
def test_install_package_with_root(script):
|
||||
"""
|
||||
Test installing a package using pip install --root
|
||||
"""
|
||||
script = reset_env()
|
||||
root_dir = script.scratch_path/'root'
|
||||
result = script.pip('install', '--root', root_dir, '-f', find_links, '--no-index', 'simple==1.0')
|
||||
normal_install_path = script.base_path / script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
|
||||
|
@ -443,7 +408,7 @@ def test_install_package_with_root():
|
|||
|
||||
# skip on win/py3 for now, see issue #782
|
||||
@pytest.mark.skipif("sys.platform == 'win32' and sys.version_info >= (3,)")
|
||||
def test_install_package_that_emits_unicode():
|
||||
def test_install_package_that_emits_unicode(script):
|
||||
"""
|
||||
Install a package with a setup.py that emits UTF-8 output and then fails.
|
||||
This works fine in Python 2, but fails in Python 3 with:
|
||||
|
@ -458,14 +423,13 @@ def test_install_package_that_emits_unicode():
|
|||
|
||||
Refs https://github.com/pypa/pip/issues/326
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = os.path.abspath(os.path.join(tests_data, 'packages', 'BrokenEmitsUTF8'))
|
||||
result = script.pip('install', to_install, expect_error=True, expect_temp=True, quiet=True)
|
||||
assert 'FakeError: this package designed to fail on install' in result.stdout
|
||||
assert 'UnicodeDecodeError' not in result.stdout
|
||||
|
||||
|
||||
def test_url_req_case_mismatch():
|
||||
def test_url_req_case_mismatch(script):
|
||||
"""
|
||||
tar ball url requirements (with no egg fragment), that happen to have upper case project names,
|
||||
should be considered equal to later requirements that reference the project name using lower case.
|
||||
|
@ -473,7 +437,6 @@ def test_url_req_case_mismatch():
|
|||
tests/packages contains Upper-1.0.tar.gz and Upper-2.0.tar.gz
|
||||
'requiresupper' has install_requires = ['upper']
|
||||
"""
|
||||
script = reset_env()
|
||||
Upper = os.path.join(find_links, 'Upper-1.0.tar.gz')
|
||||
result = script.pip('install', '--no-index', '-f', find_links, Upper, 'requiresupper')
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import os
|
||||
|
||||
from tests.lib import reset_env, packages
|
||||
from tests.lib import packages
|
||||
|
||||
|
||||
def test_install_pybundle():
|
||||
def test_install_pybundle(script):
|
||||
"""
|
||||
Test intalling a *.pybundle file
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip_install_local(os.path.join(packages, 'simplebundle.pybundle'), expect_temp=True)
|
||||
result.assert_installed('simple', editable=False)
|
||||
result.assert_installed('simple2', editable=False)
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
import os
|
||||
import textwrap
|
||||
from os.path import abspath, exists, join
|
||||
from tests.lib import tests_data, reset_env, find_links
|
||||
from tests.lib import tests_data, find_links
|
||||
from tests.lib.local_repos import local_checkout
|
||||
from tests.lib.path import Path
|
||||
from pip.locations import write_delete_marker_file
|
||||
from pip.status_codes import PREVIOUS_BUILD_DIR_ERROR
|
||||
|
||||
|
||||
def test_cleanup_after_install():
|
||||
def test_cleanup_after_install(script):
|
||||
"""
|
||||
Test clean up after installing a package.
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '--no-index', '--find-links=%s' % find_links, 'simple')
|
||||
build = script.venv_path/"build"
|
||||
src = script.venv_path/"src"
|
||||
|
@ -20,22 +19,21 @@ def test_cleanup_after_install():
|
|||
assert not exists(src), "unexpected src/ dir exists: %s" % src
|
||||
script.assert_no_temp()
|
||||
|
||||
def test_no_clean_option_blocks_cleaning_after_install():
|
||||
|
||||
def test_no_clean_option_blocks_cleaning_after_install(script):
|
||||
"""
|
||||
Test --no-clean option blocks cleaning after install
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '--no-clean', '--no-index', '--find-links=%s' % find_links, 'simple')
|
||||
build = script.venv_path/'build'/'simple'
|
||||
assert exists(build), "build/simple should still exist %s" % str(result)
|
||||
|
||||
|
||||
def test_cleanup_after_install_editable_from_hg():
|
||||
def test_cleanup_after_install_editable_from_hg(script):
|
||||
"""
|
||||
Test clean up after cloning from Mercurial.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install',
|
||||
'-e',
|
||||
'%s#egg=ScriptTest' %
|
||||
|
@ -48,12 +46,11 @@ def test_cleanup_after_install_editable_from_hg():
|
|||
script.assert_no_temp()
|
||||
|
||||
|
||||
def test_cleanup_after_install_from_local_directory():
|
||||
def test_cleanup_after_install_from_local_directory(script):
|
||||
"""
|
||||
Test clean up after installing from a local directory.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
script.pip('install', to_install, expect_error=False)
|
||||
build = script.venv_path/'build'
|
||||
|
@ -63,11 +60,10 @@ def test_cleanup_after_install_from_local_directory():
|
|||
script.assert_no_temp()
|
||||
|
||||
|
||||
def test_no_install_and_download_should_not_leave_build_dir():
|
||||
def test_no_install_and_download_should_not_leave_build_dir(script):
|
||||
"""
|
||||
It should remove build/ dir if it was pip that created
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("downloaded_packages").mkdir()
|
||||
assert not os.path.exists(script.venv_path/'/build')
|
||||
result = script.pip('install', '--no-install', 'INITools==0.2', '-d', 'downloaded_packages')
|
||||
|
@ -75,7 +71,7 @@ def test_no_install_and_download_should_not_leave_build_dir():
|
|||
assert not os.path.exists(script.venv_path/'/build'), "build/ dir should be deleted"
|
||||
|
||||
|
||||
def test_cleanup_req_satisifed_no_name():
|
||||
def test_cleanup_req_satisifed_no_name(script):
|
||||
"""
|
||||
Test cleanup when req is already satisfied, and req has no 'name'
|
||||
"""
|
||||
|
@ -86,7 +82,6 @@ def test_cleanup_req_satisifed_no_name():
|
|||
# 2) parent-0.1.tar.gz
|
||||
|
||||
dist = abspath(join(tests_data, 'packages', 'parent-0.1.tar.gz'))
|
||||
script = reset_env()
|
||||
result = script.pip('install', dist)
|
||||
result = script.pip('install', dist)
|
||||
build = script.venv_path/'build'
|
||||
|
@ -94,11 +89,10 @@ def test_cleanup_req_satisifed_no_name():
|
|||
script.assert_no_temp()
|
||||
|
||||
|
||||
def test_download_should_not_delete_existing_build_dir():
|
||||
def test_download_should_not_delete_existing_build_dir(script):
|
||||
"""
|
||||
It should not delete build/ if existing before run the command
|
||||
"""
|
||||
script = reset_env()
|
||||
script.venv_path.join("build").mkdir()
|
||||
script.venv_path.join("build", "somefile.txt").write("I am not empty!")
|
||||
script.pip('install', '--no-install', 'INITools==0.2', '-d', '.')
|
||||
|
@ -108,33 +102,33 @@ def test_download_should_not_delete_existing_build_dir():
|
|||
assert content == 'I am not empty!', "it should not affect build/ and its content"
|
||||
assert ['somefile.txt'] == os.listdir(script.venv_path/'build')
|
||||
|
||||
def test_cleanup_after_install_exception():
|
||||
|
||||
def test_cleanup_after_install_exception(script):
|
||||
"""
|
||||
Test clean up after a 'setup.py install' exception.
|
||||
"""
|
||||
script = reset_env()
|
||||
#broken==0.2broken fails during install; see packages readme file
|
||||
result = script.pip('install', '-f', find_links, '--no-index', 'broken==0.2broken', expect_error=True)
|
||||
build = script.venv_path/'build'
|
||||
assert not exists(build), "build/ dir still exists: %s" % result.stdout
|
||||
script.assert_no_temp()
|
||||
|
||||
def test_cleanup_after_egg_info_exception():
|
||||
|
||||
def test_cleanup_after_egg_info_exception(script):
|
||||
"""
|
||||
Test clean up after a 'setup.py egg_info' exception.
|
||||
"""
|
||||
script = reset_env()
|
||||
#brokenegginfo fails during egg_info; see packages readme file
|
||||
result = script.pip('install', '-f', find_links, '--no-index', 'brokenegginfo==0.1', expect_error=True)
|
||||
build = script.venv_path/'build'
|
||||
assert not exists(build), "build/ dir still exists: %s" % result.stdout
|
||||
script.assert_no_temp()
|
||||
|
||||
def test_cleanup_prevented_upon_build_dir_exception():
|
||||
|
||||
def test_cleanup_prevented_upon_build_dir_exception(script):
|
||||
"""
|
||||
Test no cleanup occurs after a PreviousBuildDirError
|
||||
"""
|
||||
script = reset_env()
|
||||
build = script.venv_path/'build'/'simple'
|
||||
os.makedirs(build)
|
||||
write_delete_marker_file(script.venv_path/'build')
|
||||
|
|
|
@ -3,10 +3,10 @@ Tests for compatibility workarounds.
|
|||
|
||||
"""
|
||||
import os
|
||||
from tests.lib import tests_data, reset_env, pyversion, assert_all_changes
|
||||
from tests.lib import tests_data, pyversion, assert_all_changes
|
||||
|
||||
|
||||
def test_debian_egg_name_workaround():
|
||||
def test_debian_egg_name_workaround(script):
|
||||
"""
|
||||
We can uninstall packages installed with the pyversion removed from the
|
||||
egg-info metadata directory name.
|
||||
|
@ -17,7 +17,6 @@ def test_debian_egg_name_workaround():
|
|||
https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.2', expect_error=True)
|
||||
|
||||
egg_info = os.path.join(
|
||||
|
@ -44,12 +43,11 @@ def test_debian_egg_name_workaround():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_setup_py_with_dos_line_endings():
|
||||
def test_setup_py_with_dos_line_endings(script):
|
||||
"""
|
||||
It doesn't choke on a setup.py file that uses DOS line endings (\\r\\n).
|
||||
|
||||
Refs https://github.com/pypa/pip/issues/237
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = os.path.abspath(os.path.join(tests_data, 'packages', 'LineEndings'))
|
||||
script.pip('install', to_install, expect_error=False)
|
||||
|
|
|
@ -2,46 +2,42 @@ import os
|
|||
import tempfile
|
||||
import textwrap
|
||||
|
||||
from tests.lib import reset_env, clear_environ, path_to_url, find_links
|
||||
from tests.lib import find_links
|
||||
|
||||
|
||||
def test_options_from_env_vars():
|
||||
def test_options_from_env_vars(script):
|
||||
"""
|
||||
Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_NO_INDEX'] = '1'
|
||||
script = reset_env(environ)
|
||||
script.environ['PIP_NO_INDEX'] = '1'
|
||||
result = script.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
|
||||
|
||||
|
||||
def test_command_line_options_override_env_vars():
|
||||
def test_command_line_options_override_env_vars(script, virtualenv):
|
||||
"""
|
||||
Test that command line options override environmental variables.
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_INDEX_URL'] = 'http://b.pypi.python.org/simple/'
|
||||
script = reset_env(environ)
|
||||
script.environ['PIP_INDEX_URL'] = 'http://b.pypi.python.org/simple/'
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Getting page http://b.pypi.python.org/simple/INITools" in result.stdout
|
||||
script = reset_env(environ)
|
||||
virtualenv.clear()
|
||||
result = script.pip('install', '-vvv', '--index-url', 'http://download.zope.org/ppix', 'INITools', expect_error=True)
|
||||
assert "b.pypi.python.org" not in result.stdout
|
||||
assert "Getting page http://download.zope.org/ppix" in result.stdout
|
||||
|
||||
|
||||
def test_env_vars_override_config_file():
|
||||
def test_env_vars_override_config_file(script, virtualenv):
|
||||
"""
|
||||
Test that environmental variables override settings in config files.
|
||||
|
||||
"""
|
||||
fd, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
|
||||
try:
|
||||
_test_env_vars_override_config_file(config_file)
|
||||
_test_env_vars_override_config_file(script, virtualenv, config_file)
|
||||
finally:
|
||||
# `os.close` is a workaround for a bug in subprocess
|
||||
# http://bugs.python.org/issue3210
|
||||
|
@ -49,10 +45,9 @@ def test_env_vars_override_config_file():
|
|||
os.remove(config_file)
|
||||
|
||||
|
||||
def _test_env_vars_override_config_file(config_file):
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
|
||||
script = reset_env(environ)
|
||||
def _test_env_vars_override_config_file(script, virtualenv, config_file):
|
||||
# set this to make pip load it
|
||||
script.environ['PIP_CONFIG_FILE'] = config_file
|
||||
# It's important that we test this particular config value ('no-index')
|
||||
# because their is/was a bug which only shows up in cases in which
|
||||
# 'config-item' and 'config_item' hash to the same value modulo the size
|
||||
|
@ -63,43 +58,39 @@ def _test_env_vars_override_config_file(config_file):
|
|||
"""))
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
|
||||
environ['PIP_NO_INDEX'] = '0'
|
||||
script = reset_env(environ)
|
||||
script.environ['PIP_NO_INDEX'] = '0'
|
||||
virtualenv.clear()
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Successfully installed INITools" in result.stdout
|
||||
|
||||
|
||||
def test_command_line_append_flags():
|
||||
def test_command_line_append_flags(script, virtualenv):
|
||||
"""
|
||||
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'
|
||||
script = reset_env(environ)
|
||||
script.environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
|
||||
script = reset_env(environ)
|
||||
virtualenv.clear()
|
||||
result = script.pip('install', '-vvv', '--find-links', find_links, 'INITools', expect_error=True)
|
||||
assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
|
||||
assert "Skipping link %s" % find_links in result.stdout
|
||||
|
||||
|
||||
def test_command_line_appends_correctly():
|
||||
def test_command_line_appends_correctly(script):
|
||||
"""
|
||||
Test multiple appending options set by environmental variables.
|
||||
|
||||
"""
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com %s' % find_links
|
||||
script = reset_env(environ)
|
||||
script.environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com %s' % find_links
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
|
||||
assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout, result.stdout
|
||||
assert "Skipping link %s" % find_links in result.stdout
|
||||
|
||||
|
||||
def test_config_file_override_stack():
|
||||
def test_config_file_override_stack(script, virtualenv):
|
||||
"""
|
||||
Test config files (global, overriding a global config with a
|
||||
local, overriding all with a command line flag).
|
||||
|
@ -107,7 +98,7 @@ def test_config_file_override_stack():
|
|||
"""
|
||||
fd, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
|
||||
try:
|
||||
_test_config_file_override_stack(config_file)
|
||||
_test_config_file_override_stack(script, virtualenv, config_file)
|
||||
finally:
|
||||
# `os.close` is a workaround for a bug in subprocess
|
||||
# http://bugs.python.org/issue3210
|
||||
|
@ -115,17 +106,15 @@ def test_config_file_override_stack():
|
|||
os.remove(config_file)
|
||||
|
||||
|
||||
def _test_config_file_override_stack(config_file):
|
||||
environ = clear_environ(os.environ.copy())
|
||||
environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
|
||||
script = reset_env(environ)
|
||||
def _test_config_file_override_stack(script, virtualenv, config_file):
|
||||
script.environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
|
||||
(script.scratch_path/config_file).write(textwrap.dedent("""\
|
||||
[global]
|
||||
index-url = http://download.zope.org/ppix
|
||||
"""))
|
||||
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
|
||||
assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
|
||||
script = reset_env(environ)
|
||||
virtualenv.clear()
|
||||
(script.scratch_path/config_file).write(textwrap.dedent("""\
|
||||
[global]
|
||||
index-url = http://download.zope.org/ppix
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
import textwrap
|
||||
|
||||
from tests.lib import reset_env
|
||||
from tests.lib.path import Path
|
||||
|
||||
|
||||
def test_download_if_requested():
|
||||
def test_download_if_requested(script):
|
||||
"""
|
||||
It should download (in the scratch path) and not install if requested.
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.1', '-d', '.', expect_error=True)
|
||||
assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
|
||||
assert script.site_packages/ 'initools' not in result.files_created
|
||||
|
||||
|
||||
def test_download_wheel():
|
||||
def test_download_wheel(script):
|
||||
"""
|
||||
Test using "pip install --download" to download a *.whl archive.
|
||||
FIXME: this test could use a local --find-links dir, but -d with local
|
||||
--find-links has a bug https://github.com/pypa/pip/issues/1111
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
result = script.pip('install', '--use-wheel',
|
||||
'-f', 'https://bitbucket.org/pypa/pip-test-package/downloads',
|
||||
'-d', '.', 'pip-test-package')
|
||||
|
@ -30,12 +25,10 @@ def test_download_wheel():
|
|||
assert script.site_packages/ 'piptestpackage' not in result.files_created
|
||||
|
||||
|
||||
def test_single_download_from_requirements_file():
|
||||
def test_single_download_from_requirements_file(script):
|
||||
"""
|
||||
It should support download (in the scratch path) from PyPi from a requirements file
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
|
||||
INITools==0.1
|
||||
"""))
|
||||
|
@ -44,12 +37,10 @@ def test_single_download_from_requirements_file():
|
|||
assert script.site_packages/ 'initools' not in result.files_created
|
||||
|
||||
|
||||
def test_download_should_download_dependencies():
|
||||
def test_download_should_download_dependencies(script):
|
||||
"""
|
||||
It should download dependencies (in the scratch path)
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'Paste[openid]==1.7.5.1', '-d', '.', expect_error=True)
|
||||
assert Path('scratch')/ 'Paste-1.7.5.1.tar.gz' in result.files_created
|
||||
openid_tarball_prefix = str(Path('scratch')/ 'python-openid-')
|
||||
|
@ -57,12 +48,10 @@ def test_download_should_download_dependencies():
|
|||
assert script.site_packages/ 'openid' not in result.files_created
|
||||
|
||||
|
||||
def test_download_should_skip_existing_files():
|
||||
def test_download_should_skip_existing_files(script):
|
||||
"""
|
||||
It should not download files already existing in the scratch dir
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
|
||||
INITools==0.1
|
||||
"""))
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
from os.path import join
|
||||
|
||||
from tests.lib import reset_env
|
||||
|
||||
|
||||
def test_simple_extras_install_from_pypi():
|
||||
def test_simple_extras_install_from_pypi(script):
|
||||
"""
|
||||
Test installing a package from PyPI using extras dependency Paste[openid].
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'Paste[openid]==1.7.5.1', expect_stderr=True)
|
||||
initools_folder = script.site_packages / 'openid'
|
||||
assert initools_folder in result.files_created, result.files_created
|
||||
|
||||
|
||||
def test_no_extras_uninstall():
|
||||
def test_no_extras_uninstall(script):
|
||||
"""
|
||||
No extras dependency gets uninstalled when the root package is uninstalled
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'Paste[openid]==1.7.5.1', expect_stderr=True)
|
||||
assert join(script.site_packages, 'paste') in result.files_created, sorted(result.files_created.keys())
|
||||
assert join(script.site_packages, 'openid') in result.files_created, sorted(result.files_created.keys())
|
||||
|
|
|
@ -3,12 +3,11 @@ import textwrap
|
|||
|
||||
from pip.backwardcompat import urllib
|
||||
|
||||
from tests.lib import reset_env, pyversion, tests_data, path_to_url
|
||||
from tests.lib import pyversion, tests_data, path_to_url
|
||||
|
||||
|
||||
def test_find_links_relative_path():
|
||||
def test_find_links_relative_path(script):
|
||||
"""Test find-links as a relative path."""
|
||||
script = reset_env()
|
||||
result = script.pip(
|
||||
'install',
|
||||
'parent==0.1',
|
||||
|
@ -22,9 +21,8 @@ def test_find_links_relative_path():
|
|||
assert initools_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_find_links_requirements_file_relative_path():
|
||||
def test_find_links_requirements_file_relative_path(script):
|
||||
"""Test find-links as a relative path to a reqs file."""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
|
||||
--no-index
|
||||
--find-links=../../../data/packages/
|
||||
|
@ -41,23 +39,21 @@ def test_find_links_requirements_file_relative_path():
|
|||
assert initools_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_from_file_index_hash_link():
|
||||
def test_install_from_file_index_hash_link(script):
|
||||
"""
|
||||
Test that a pkg can be installed from a file:// index using a link with a hash
|
||||
"""
|
||||
script = reset_env()
|
||||
index_url = path_to_url(os.path.join(tests_data, 'indexes', 'simple'))
|
||||
result = script.pip('install', '-i', index_url, 'simple==1.0')
|
||||
egg_info_folder = script.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
|
||||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_file_index_url_quoting():
|
||||
def test_file_index_url_quoting(script):
|
||||
"""
|
||||
Test url quoting of file index url with a space
|
||||
"""
|
||||
index_url = path_to_url(os.path.join(tests_data, 'indexes', urllib.quote('in dex')))
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-vvv', '--index-url', index_url, 'simple', expect_error=False)
|
||||
assert (script.site_packages/'simple') in result.files_created, str(result.stdout)
|
||||
assert (script.site_packages/'simple-1.0-py%s.egg-info' % pyversion) in result.files_created, str(result)
|
||||
|
|
|
@ -8,18 +8,17 @@ from mock import patch
|
|||
from pip.backwardcompat import urllib
|
||||
from pip.req import Requirements, parse_editable, parse_requirements
|
||||
|
||||
from tests.lib import reset_env, pyversion, tests_data, path_to_url, find_links
|
||||
from tests.lib import pyversion, tests_data, path_to_url, find_links
|
||||
from tests.lib.local_repos import local_checkout
|
||||
from tests.lib.path import Path
|
||||
|
||||
|
||||
def test_requirements_file():
|
||||
def test_requirements_file(script):
|
||||
"""
|
||||
Test installing from a requirements file.
|
||||
|
||||
"""
|
||||
other_lib_name, other_lib_version = 'anyjson', '0.3'
|
||||
script = reset_env()
|
||||
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
|
||||
INITools==0.2
|
||||
# and something else to test out:
|
||||
|
@ -33,12 +32,11 @@ def test_requirements_file():
|
|||
assert result.files_created[script.site_packages/fn].dir
|
||||
|
||||
|
||||
def test_schema_check_in_requirements_file():
|
||||
def test_schema_check_in_requirements_file(script):
|
||||
"""
|
||||
Test installing from a requirements file with an invalid vcs schema..
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("file-egg-req.txt").write(textwrap.dedent("""\
|
||||
git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
|
||||
"""))
|
||||
|
@ -47,13 +45,12 @@ def test_schema_check_in_requirements_file():
|
|||
script.pip("install", "-vvv", "-r", script.scratch_path / "file-egg-req.txt")
|
||||
|
||||
|
||||
def test_relative_requirements_file():
|
||||
def test_relative_requirements_file(script):
|
||||
"""
|
||||
Test installing from a requirements file with a relative path with an egg= definition..
|
||||
|
||||
"""
|
||||
url = path_to_url(os.path.join(tests_data, 'packages', '..', 'packages', 'FSPkg')) + '#egg=FSPkg'
|
||||
script = reset_env()
|
||||
script.scratch_path.join("file-egg-req.txt").write(textwrap.dedent("""\
|
||||
%s
|
||||
""" % url))
|
||||
|
@ -62,13 +59,12 @@ def test_relative_requirements_file():
|
|||
assert (script.site_packages/'fspkg') in result.files_created, str(result.stdout)
|
||||
|
||||
|
||||
def test_multiple_requirements_files():
|
||||
def test_multiple_requirements_files(script):
|
||||
"""
|
||||
Test installing from multiple nested requirements files.
|
||||
|
||||
"""
|
||||
other_lib_name, other_lib_version = 'anyjson', '0.3'
|
||||
script = reset_env()
|
||||
script.scratch_path.join("initools-req.txt").write(textwrap.dedent("""\
|
||||
-e %s@10#egg=INITools-dev
|
||||
-r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
|
||||
|
@ -83,8 +79,7 @@ def test_multiple_requirements_files():
|
|||
assert script.venv/'src'/'initools' in result.files_created
|
||||
|
||||
|
||||
def test_respect_order_in_requirements_file():
|
||||
script = reset_env()
|
||||
def test_respect_order_in_requirements_file(script):
|
||||
script.scratch_path.join("frameworks-req.txt").write(textwrap.dedent("""\
|
||||
parent
|
||||
child
|
||||
|
@ -104,9 +99,7 @@ def test_respect_order_in_requirements_file():
|
|||
'be "simple" but was "%s"' % downloaded[2]
|
||||
|
||||
|
||||
|
||||
def test_install_local_editable_with_extras():
|
||||
script = reset_env()
|
||||
def test_install_local_editable_with_extras(script):
|
||||
to_install = os.path.abspath(os.path.join(tests_data, 'packages', 'LocalExtras'))
|
||||
res = script.pip('install', '-e', to_install + '[bar]', expect_error=False)
|
||||
assert script.site_packages/'easy-install.pth' in res.files_updated, str(result)
|
||||
|
|
|
@ -6,29 +6,26 @@ from os.path import join
|
|||
|
||||
import pytest
|
||||
|
||||
from tests.lib import (reset_env, assert_all_changes, src_folder, pyversion,
|
||||
_create_test_package, _change_test_package_version,
|
||||
find_links)
|
||||
from tests.lib import (assert_all_changes, src_folder, pyversion, find_links,
|
||||
_create_test_package, _change_test_package_version)
|
||||
from tests.lib.local_repos import local_checkout
|
||||
|
||||
|
||||
def test_no_upgrade_unless_requested():
|
||||
def test_no_upgrade_unless_requested(script):
|
||||
"""
|
||||
No upgrade if not specifically requested.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', 'INITools==0.1', expect_error=True)
|
||||
result = script.pip('install', 'INITools', expect_error=True)
|
||||
assert not result.files_created, 'pip install INITools upgraded when it should not have'
|
||||
|
||||
|
||||
def test_upgrade_to_specific_version():
|
||||
def test_upgrade_to_specific_version(script):
|
||||
"""
|
||||
It does upgrade to specific version requested.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', 'INITools==0.1', expect_error=True)
|
||||
result = script.pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert result.files_created, 'pip install with specific version did not upgrade'
|
||||
|
@ -36,38 +33,33 @@ def test_upgrade_to_specific_version():
|
|||
assert script.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created
|
||||
|
||||
|
||||
def test_upgrade_if_requested():
|
||||
def test_upgrade_if_requested(script):
|
||||
"""
|
||||
And it does upgrade if requested.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', 'INITools==0.1', expect_error=True)
|
||||
result = script.pip('install', '--upgrade', 'INITools', expect_error=True)
|
||||
assert result.files_created, 'pip install --upgrade did not upgrade'
|
||||
assert script.site_packages/'INITools-0.1-py%s.egg-info' % pyversion not in result.files_created
|
||||
|
||||
|
||||
def test_upgrade_with_newest_already_installed():
|
||||
def test_upgrade_with_newest_already_installed(script):
|
||||
"""
|
||||
If the newest version of a package is already installed, the package should
|
||||
not be reinstalled and the user should be informed.
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple')
|
||||
result = script.pip('install', '--upgrade', '-f', find_links, '--no-index', 'simple')
|
||||
assert not result.files_created, 'simple upgraded when it should not have'
|
||||
assert 'already up-to-date' in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_upgrade_force_reinstall_newest():
|
||||
def test_upgrade_force_reinstall_newest(script):
|
||||
"""
|
||||
Force reinstallation of a package even if it is already at its newest
|
||||
version if --force-reinstall is supplied.
|
||||
"""
|
||||
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools')
|
||||
assert script.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = script.pip('install', '--upgrade', '--force-reinstall', 'INITools')
|
||||
|
@ -76,12 +68,11 @@ def test_upgrade_force_reinstall_newest():
|
|||
assert_all_changes(result, result3, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_before_upgrade():
|
||||
def test_uninstall_before_upgrade(script):
|
||||
"""
|
||||
Automatic uninstall-before-upgrade.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert script.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = script.pip('install', 'INITools==0.3', expect_error=True)
|
||||
|
@ -90,12 +81,11 @@ def test_uninstall_before_upgrade():
|
|||
assert_all_changes(result, result3, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_before_upgrade_from_url():
|
||||
def test_uninstall_before_upgrade_from_url(script):
|
||||
"""
|
||||
Automatic uninstall-before-upgrade from URL.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.2', expect_error=True)
|
||||
assert script.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = script.pip('install', 'http://pypi.python.org/packages/source/I/INITools/INITools-0.3.tar.gz', expect_error=True)
|
||||
|
@ -104,13 +94,12 @@ def test_uninstall_before_upgrade_from_url():
|
|||
assert_all_changes(result, result3, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_upgrade_to_same_version_from_url():
|
||||
def test_upgrade_to_same_version_from_url(script):
|
||||
"""
|
||||
When installing from a URL the same version that is already installed, no
|
||||
need to uninstall and reinstall if --upgrade is not specified.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.3', expect_error=True)
|
||||
assert script.site_packages/ 'initools' in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = script.pip('install', 'http://pypi.python.org/packages/source/I/INITools/INITools-0.3.tar.gz', expect_error=True)
|
||||
|
@ -119,12 +108,11 @@ def test_upgrade_to_same_version_from_url():
|
|||
assert_all_changes(result, result3, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_upgrade_from_reqs_file():
|
||||
def test_upgrade_from_reqs_file(script):
|
||||
"""
|
||||
Upgrade from a requirements file.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""\
|
||||
PyLogo<0.4
|
||||
# and something else to test out:
|
||||
|
@ -141,13 +129,12 @@ def test_upgrade_from_reqs_file():
|
|||
assert_all_changes(install_result, uninstall_result, [script.venv/'build', 'cache', script.scratch/'test-req.txt'])
|
||||
|
||||
|
||||
def test_uninstall_rollback():
|
||||
def test_uninstall_rollback(script):
|
||||
"""
|
||||
Test uninstall-rollback (using test package with a setup.py
|
||||
crafted to fail on install).
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-f', find_links, '--no-index', 'broken==0.1')
|
||||
assert script.site_packages / 'broken.py' in result.files_created, list(result.files_created.keys())
|
||||
result2 = script.pip('install', '-f', find_links, '--no-index', 'broken==0.2broken', expect_error=True)
|
||||
|
@ -155,14 +142,14 @@ def test_uninstall_rollback():
|
|||
assert script.run('python', '-c', "import broken; print(broken.VERSION)").stdout == '0.1\n'
|
||||
assert_all_changes(result.files_after, result2, [script.venv/'build', 'pip-log.txt'])
|
||||
|
||||
|
||||
# Issue #530 - temporarily disable flaky test
|
||||
@pytest.mark.skipif
|
||||
def test_editable_git_upgrade():
|
||||
def test_editable_git_upgrade(script):
|
||||
"""
|
||||
Test installing an editable git package from a repository, upgrading the repository,
|
||||
installing again, and check it gets the newer version
|
||||
"""
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.pip('install', '-e', '%s#egg=version_pkg' % ('git+file://' + version_pkg_path))
|
||||
version = script.run('version_pkg')
|
||||
|
@ -173,12 +160,11 @@ def test_editable_git_upgrade():
|
|||
assert 'some different version' in version2.stdout, "Output: %s" % (version2.stdout)
|
||||
|
||||
|
||||
def test_should_not_install_always_from_cache():
|
||||
def test_should_not_install_always_from_cache(script):
|
||||
"""
|
||||
If there is an old cached package, pip should download the newer version
|
||||
Related to issue #175
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', 'INITools==0.2', expect_error=True)
|
||||
script.pip('uninstall', '-y', 'INITools')
|
||||
result = script.pip('install', 'INITools==0.1', expect_error=True)
|
||||
|
@ -186,21 +172,19 @@ def test_should_not_install_always_from_cache():
|
|||
assert script.site_packages/'INITools-0.1-py%s.egg-info' % pyversion in result.files_created
|
||||
|
||||
|
||||
def test_install_with_ignoreinstalled_requested():
|
||||
def test_install_with_ignoreinstalled_requested(script):
|
||||
"""
|
||||
It installs package if ignore installed is set.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', 'INITools==0.1', expect_error=True)
|
||||
result = script.pip('install', '-I', 'INITools', expect_error=True)
|
||||
assert result.files_created, 'pip install -I did not install'
|
||||
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():
|
||||
def test_upgrade_vcs_req_with_no_dists_found(script):
|
||||
"""It can upgrade a VCS requirement that has no distributions otherwise."""
|
||||
script = reset_env()
|
||||
req = "%s#egg=pip-test-package" % local_checkout(
|
||||
"git+http://github.com/pypa/pip-test-package.git")
|
||||
script.pip("install", req)
|
||||
|
@ -208,9 +192,8 @@ def test_upgrade_vcs_req_with_no_dists_found():
|
|||
assert not result.returncode
|
||||
|
||||
|
||||
def test_upgrade_vcs_req_with_dist_found():
|
||||
def test_upgrade_vcs_req_with_dist_found(script):
|
||||
"""It can upgrade a VCS requirement that has distributions on the index."""
|
||||
script = reset_env()
|
||||
# TODO(pnasrat) Using local_checkout fails on windows - oddness with the test path urls/git.
|
||||
req = "%s#egg=virtualenv" % "git+git://github.com/pypa/virtualenv@c21fef2c2d53cf19f49bcc37f9c058a33fb50499"
|
||||
script.pip("install", req)
|
||||
|
@ -226,8 +209,8 @@ class TestUpgradeSetuptools(object):
|
|||
note: virtualenv-1.10 contains setuptools-0.9.7
|
||||
"""
|
||||
|
||||
def prep_ve(self, version, distribute=False):
|
||||
self.script = reset_env()
|
||||
def prep_ve(self, script, version, distribute=False):
|
||||
self.script = script
|
||||
self.script.pip_install_local('virtualenv==%s' %version)
|
||||
args = ['virtualenv', self.script.scratch_path/'VE']
|
||||
if distribute:
|
||||
|
@ -241,38 +224,38 @@ class TestUpgradeSetuptools(object):
|
|||
self.script.run(self.ve_bin/'python', 'setup.py', 'install', cwd=src_folder, expect_stderr=True)
|
||||
|
||||
@pytest.mark.skipif("sys.version_info >= (3,0)")
|
||||
def test_py2_from_setuptools_6_to_setuptools_7(self):
|
||||
self.prep_ve('1.9.1')
|
||||
def test_py2_from_setuptools_6_to_setuptools_7(self, script):
|
||||
self.prep_ve(script, '1.9.1')
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.6c11" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_py2_py3_from_distribute_6_to_setuptools_7(self):
|
||||
self.prep_ve('1.9.1', distribute=True)
|
||||
def test_py2_py3_from_distribute_6_to_setuptools_7(self, script):
|
||||
self.prep_ve(script, '1.9.1', distribute=True)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: distribute 0.6.34" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
"distribute (0.7.3)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7(self):
|
||||
self.prep_ve('1.10')
|
||||
def test_from_setuptools_7_to_setuptools_7(self, script):
|
||||
self.prep_ve(script, '1.10')
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.9.7" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7_using_wheel(self):
|
||||
self.prep_ve('1.10')
|
||||
def test_from_setuptools_7_to_setuptools_7_using_wheel(self, script):
|
||||
self.prep_ve(script, '1.10')
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--use-wheel', '--no-index', '--find-links=%s' % find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.9.7" in result.stdout
|
||||
assert 'setuptools-0.9.8.dist-info' in str(result.files_created) #only wheels use dist-info
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7_with_distribute_7_installed(self):
|
||||
self.prep_ve('1.9.1', distribute=True)
|
||||
def test_from_setuptools_7_to_setuptools_7_with_distribute_7_installed(self, script):
|
||||
self.prep_ve(script, '1.9.1', distribute=True)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % find_links, '-U', 'setuptools')
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % find_links, 'setuptools==0.9.6')
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
|
|
|
@ -13,8 +13,7 @@ import pytest
|
|||
from pip.backwardcompat import uses_pycache
|
||||
|
||||
from tests.lib.local_repos import local_checkout
|
||||
from tests.lib import (tests_data, reset_env, pyversion, assert_all_changes,
|
||||
find_links)
|
||||
from tests.lib import tests_data, pyversion, assert_all_changes, find_links
|
||||
|
||||
|
||||
def _patch_dist_in_site_packages(script):
|
||||
|
@ -42,33 +41,33 @@ def _patch_dist_in_site_packages(script):
|
|||
@pytest.mark.skipif("hasattr(sys, 'pypy_version_info')")
|
||||
class Tests_UserSite:
|
||||
|
||||
def test_reset_env_system_site_packages_usersite(self):
|
||||
def test_reset_env_system_site_packages_usersite(self, script, virtualenv):
|
||||
"""
|
||||
reset_env(system_site_packages=True) produces env where a --user install can be found using pkg_resources
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.pip('install', '--user', 'INITools==0.2')
|
||||
result = script.run('python', '-c', "import pkg_resources; print(pkg_resources.get_distribution('initools').project_name)")
|
||||
project_name = result.stdout.strip()
|
||||
assert 'INITools'== project_name, "'%s' should be 'INITools'" %project_name
|
||||
|
||||
|
||||
def test_install_subversion_usersite_editable_with_distribute(self):
|
||||
def test_install_subversion_usersite_editable_with_distribute(self, script, virtualenv):
|
||||
"""
|
||||
Test installing current directory ('.') into usersite after installing distribute
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
result = script.pip('install', '--user', '-e',
|
||||
'%s#egg=initools-dev' %
|
||||
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
|
||||
result.assert_installed('INITools', use_user_site=True)
|
||||
|
||||
|
||||
def test_install_curdir_usersite(self):
|
||||
def test_install_curdir_usersite(self, script, virtualenv):
|
||||
"""
|
||||
Test installing current directory ('.') into usersite
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
run_from = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
result = script.pip('install', '--user', curdir, cwd=run_from, expect_error=False)
|
||||
fspkg_folder = script.user_site/'fspkg'
|
||||
|
@ -77,23 +76,19 @@ class Tests_UserSite:
|
|||
|
||||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_user_venv_nositepkgs_fails(self):
|
||||
def test_install_user_venv_nositepkgs_fails(self, script):
|
||||
"""
|
||||
user install in virtualenv (with no system packages) fails with message
|
||||
"""
|
||||
script = reset_env()
|
||||
run_from = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
result = script.pip('install', '--user', curdir, cwd=run_from, expect_error=True)
|
||||
assert "Can not perform a '--user' install. User site-packages are not visible in this virtualenv." in result.stdout
|
||||
|
||||
|
||||
def test_install_user_conflict_in_usersite(self):
|
||||
def test_install_user_conflict_in_usersite(self, script, virtualenv):
|
||||
"""
|
||||
Test user install with conflict in usersite updates usersite.
|
||||
"""
|
||||
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
result1 = script.pip('install', '--user', 'INITools==0.3')
|
||||
result2 = script.pip('install', '--user', 'INITools==0.1')
|
||||
|
||||
|
@ -103,12 +98,10 @@ class Tests_UserSite:
|
|||
assert egg_info_folder in result2.files_created, str(result2)
|
||||
assert not isfile(initools_v3_file), initools_v3_file
|
||||
|
||||
|
||||
def test_install_user_conflict_in_globalsite(self):
|
||||
def test_install_user_conflict_in_globalsite(self, script, virtualenv):
|
||||
"""
|
||||
Test user install with conflict in global site ignores site and installs to usersite
|
||||
"""
|
||||
|
||||
# the test framework only supports testing using virtualenvs
|
||||
# the sys.path ordering for virtualenvs with --system-site-packages is this: virtualenv-site, user-site, global-site
|
||||
# this test will use 2 modifications to simulate the user-site/global-site relationship
|
||||
|
@ -116,7 +109,7 @@ class Tests_UserSite:
|
|||
# if we don't patch this, pip will return an installation error: "Will not install to the usersite because it will lack sys.path precedence..."
|
||||
# 2) adding usersite to PYTHONPATH, so usersite as sys.path precedence over the virtualenv site
|
||||
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.environ["PYTHONPATH"] = script.base_path / script.user_site
|
||||
_patch_dist_in_site_packages(script)
|
||||
|
||||
|
@ -135,12 +128,10 @@ class Tests_UserSite:
|
|||
assert isdir(egg_info_folder)
|
||||
assert isdir(initools_folder)
|
||||
|
||||
|
||||
def test_upgrade_user_conflict_in_globalsite(self):
|
||||
def test_upgrade_user_conflict_in_globalsite(self, script, virtualenv):
|
||||
"""
|
||||
Test user install/upgrade with conflict in global site ignores site and installs to usersite
|
||||
"""
|
||||
|
||||
# the test framework only supports testing using virtualenvs
|
||||
# the sys.path ordering for virtualenvs with --system-site-packages is this: virtualenv-site, user-site, global-site
|
||||
# this test will use 2 modifications to simulate the user-site/global-site relationship
|
||||
|
@ -148,7 +139,7 @@ class Tests_UserSite:
|
|||
# if we don't patch this, pip will return an installation error: "Will not install to the usersite because it will lack sys.path precedence..."
|
||||
# 2) adding usersite to PYTHONPATH, so usersite as sys.path precedence over the virtualenv site
|
||||
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.environ["PYTHONPATH"] = script.base_path / script.user_site
|
||||
_patch_dist_in_site_packages(script)
|
||||
|
||||
|
@ -167,12 +158,10 @@ class Tests_UserSite:
|
|||
assert isdir(egg_info_folder), result2.stdout
|
||||
assert isdir(initools_folder)
|
||||
|
||||
|
||||
def test_install_user_conflict_in_globalsite_and_usersite(self):
|
||||
def test_install_user_conflict_in_globalsite_and_usersite(self, script, virtualenv):
|
||||
"""
|
||||
Test user install with conflict in globalsite and usersite ignores global site and updates usersite.
|
||||
"""
|
||||
|
||||
# the test framework only supports testing using virtualenvs.
|
||||
# the sys.path ordering for virtualenvs with --system-site-packages is this: virtualenv-site, user-site, global-site.
|
||||
# this test will use 2 modifications to simulate the user-site/global-site relationship
|
||||
|
@ -180,7 +169,7 @@ class Tests_UserSite:
|
|||
# if we don't patch this, pip will return an installation error: "Will not install to the usersite because it will lack sys.path precedence..."
|
||||
# 2) adding usersite to PYTHONPATH, so usersite as sys.path precedence over the virtualenv site
|
||||
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.environ["PYTHONPATH"] = script.base_path / script.user_site
|
||||
_patch_dist_in_site_packages(script)
|
||||
|
||||
|
@ -200,12 +189,11 @@ class Tests_UserSite:
|
|||
assert isdir(egg_info_folder)
|
||||
assert isdir(initools_folder)
|
||||
|
||||
|
||||
def test_install_user_in_global_virtualenv_with_conflict_fails(self):
|
||||
def test_install_user_in_global_virtualenv_with_conflict_fails(self, script, virtualenv):
|
||||
"""
|
||||
Test user install in --system-site-packages virtualenv with conflict in site fails.
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
result1 = script.pip('install', 'INITools==0.2')
|
||||
result2 = script.pip('install', '--user', 'INITools==0.1', expect_error=True)
|
||||
resultp = script.run('python', '-c', "import pkg_resources; print(pkg_resources.get_distribution('initools').location)")
|
||||
|
@ -213,22 +201,20 @@ class Tests_UserSite:
|
|||
assert "Will not install to the user site because it will lack sys.path precedence to %s in %s" \
|
||||
% ('INITools', dist_location) in result2.stdout, result2.stdout
|
||||
|
||||
|
||||
def test_uninstall_from_usersite(self):
|
||||
def test_uninstall_from_usersite(self, script, virtualenv):
|
||||
"""
|
||||
Test uninstall from usersite
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
result1 = script.pip('install', '--user', 'INITools==0.3')
|
||||
result2 = script.pip('uninstall', '-y', 'INITools')
|
||||
assert_all_changes(result1, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_editable_from_usersite(self):
|
||||
def test_uninstall_editable_from_usersite(self, script, virtualenv):
|
||||
"""
|
||||
Test uninstall editable local user install
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.user_site_path.makedirs()
|
||||
|
||||
#install
|
||||
|
@ -244,12 +230,11 @@ class Tests_UserSite:
|
|||
assert_all_changes(result1, result2,
|
||||
[script.venv/'build', 'cache', script.user_site/'easy-install.pth'])
|
||||
|
||||
|
||||
def test_install_user_wheel(self):
|
||||
def test_install_user_wheel(self, script, virtualenv):
|
||||
"""
|
||||
Test user install from wheel
|
||||
"""
|
||||
script = reset_env(system_site_packages=True)
|
||||
virtualenv.system_site_packages = True
|
||||
script.pip_install_local('wheel')
|
||||
result = script.pip('install', 'simple.dist==0.1', '--user', '--use-wheel',
|
||||
'--no-index', '--find-links='+find_links)
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
from tests.lib import (reset_env,
|
||||
_create_test_package, _change_test_package_version)
|
||||
from tests.lib import _create_test_package, _change_test_package_version
|
||||
from tests.lib.local_repos import local_checkout
|
||||
|
||||
|
||||
def test_install_editable_from_git_with_https():
|
||||
def test_install_editable_from_git_with_https(script):
|
||||
"""
|
||||
Test cloning from Git with https.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e',
|
||||
'%s#egg=pip-test-package' %
|
||||
local_checkout('git+https://github.com/pypa/pip-test-package.git'),
|
||||
|
@ -15,11 +13,10 @@ def test_install_editable_from_git_with_https():
|
|||
result.assert_installed('pip-test-package', with_files=['.git'])
|
||||
|
||||
|
||||
def test_git_with_sha1_revisions():
|
||||
def test_git_with_sha1_revisions(script):
|
||||
"""
|
||||
Git backend should be able to install from SHA1 revisions
|
||||
"""
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
_change_test_package_version(script, version_pkg_path)
|
||||
sha1 = script.run('git', 'rev-parse', 'HEAD~1', cwd=version_pkg_path).stdout.strip()
|
||||
|
@ -28,11 +25,10 @@ def test_git_with_sha1_revisions():
|
|||
assert '0.1' in version.stdout, version.stdout
|
||||
|
||||
|
||||
def test_git_with_branch_name_as_revision():
|
||||
def test_git_with_branch_name_as_revision(script):
|
||||
"""
|
||||
Git backend should be able to install from branch names
|
||||
"""
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.run('git', 'checkout', '-b', 'test_branch', expect_stderr=True, cwd=version_pkg_path)
|
||||
_change_test_package_version(script, version_pkg_path)
|
||||
|
@ -41,11 +37,10 @@ def test_git_with_branch_name_as_revision():
|
|||
assert 'some different version' in version.stdout
|
||||
|
||||
|
||||
def test_git_with_tag_name_as_revision():
|
||||
def test_git_with_tag_name_as_revision(script):
|
||||
"""
|
||||
Git backend should be able to install from tag names
|
||||
"""
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.run('git', 'tag', 'test_tag', expect_stderr=True, cwd=version_pkg_path)
|
||||
_change_test_package_version(script, version_pkg_path)
|
||||
|
@ -54,11 +49,10 @@ def test_git_with_tag_name_as_revision():
|
|||
assert '0.1' in version.stdout
|
||||
|
||||
|
||||
def test_git_with_tag_name_and_update():
|
||||
def test_git_with_tag_name_and_update(script):
|
||||
"""
|
||||
Test cloning a git repository and updating to a different version.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e', '%s#egg=pip-test-package' %
|
||||
local_checkout('git+http://github.com/pypa/pip-test-package.git'),
|
||||
expect_error=True)
|
||||
|
@ -70,12 +64,11 @@ def test_git_with_tag_name_and_update():
|
|||
assert '0.1.2' in result.stdout
|
||||
|
||||
|
||||
def test_git_branch_should_not_be_changed():
|
||||
def test_git_branch_should_not_be_changed(script):
|
||||
"""
|
||||
Editable installations should not change branch
|
||||
related to issue #32 and #161
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-e', '%s#egg=pip-test-package' %
|
||||
local_checkout('git+http://github.com/pypa/pip-test-package.git'),
|
||||
expect_error=True)
|
||||
|
@ -84,43 +77,39 @@ def test_git_branch_should_not_be_changed():
|
|||
assert '* master' in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_git_with_non_editable_unpacking():
|
||||
def test_git_with_non_editable_unpacking(script):
|
||||
"""
|
||||
Test cloning a git repository from a non-editable URL with a given tag.
|
||||
"""
|
||||
script = reset_env()
|
||||
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'
|
||||
), expect_error=True)
|
||||
assert '0.1.2' in result.stdout
|
||||
|
||||
|
||||
def test_git_with_editable_where_egg_contains_dev_string():
|
||||
def test_git_with_editable_where_egg_contains_dev_string(script):
|
||||
"""
|
||||
Test cloning a git repository from an editable url which contains "dev" string
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e', '%s#egg=django-devserver' %
|
||||
local_checkout('git+git://github.com/dcramer/django-devserver.git'))
|
||||
result.assert_installed('django-devserver', with_files=['.git'])
|
||||
|
||||
|
||||
def test_git_with_non_editable_where_egg_contains_dev_string():
|
||||
def test_git_with_non_editable_where_egg_contains_dev_string(script):
|
||||
"""
|
||||
Test cloning a git repository from a non-editable url which contains "dev" string
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '%s#egg=django-devserver' %
|
||||
local_checkout('git+git://github.com/dcramer/django-devserver.git'))
|
||||
devserver_folder = script.site_packages/'devserver'
|
||||
assert devserver_folder in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_git_with_ambiguous_revs():
|
||||
def test_git_with_ambiguous_revs(script):
|
||||
"""
|
||||
Test git with two "names" (tag/branch) pointing to the same commit
|
||||
"""
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
package_url = 'git+file://%s@0.1#egg=version_pkg' % (version_pkg_path.abspath.replace('\\', '/'))
|
||||
script.run('git', 'tag', '0.1', cwd=version_pkg_path)
|
||||
|
@ -131,9 +120,8 @@ def test_git_with_ambiguous_revs():
|
|||
result.assert_installed('version-pkg', with_files=['.git'])
|
||||
|
||||
|
||||
def test_git_works_with_editable_non_origin_repo():
|
||||
def test_git_works_with_editable_non_origin_repo(script):
|
||||
# set up, create a git repo and install it as editable from a local directory path
|
||||
script = reset_env()
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.pip('install', '-e', version_pkg_path.abspath)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
|||
from mock import patch
|
||||
|
||||
from pip.vcs.git import Git
|
||||
from tests.lib import reset_env, _create_test_package
|
||||
from tests.lib import _create_test_package
|
||||
from tests.lib.git_submodule_helpers import (
|
||||
_change_test_package_submodule,
|
||||
_pull_in_submodule_changes_to_module,
|
||||
|
@ -13,8 +13,7 @@ from tests.lib.git_submodule_helpers import (
|
|||
)
|
||||
|
||||
|
||||
def test_get_refs_should_return_tag_name_and_commit_pair():
|
||||
script = reset_env()
|
||||
def test_get_refs_should_return_tag_name_and_commit_pair(script):
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.run('git', 'tag', '0.1', cwd=version_pkg_path)
|
||||
script.run('git', 'tag', '0.2', cwd=version_pkg_path)
|
||||
|
@ -26,8 +25,7 @@ def test_get_refs_should_return_tag_name_and_commit_pair():
|
|||
assert result['0.2'] == commit, result
|
||||
|
||||
|
||||
def test_get_refs_should_return_branch_name_and_commit_pair():
|
||||
script = reset_env()
|
||||
def test_get_refs_should_return_branch_name_and_commit_pair(script):
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
|
||||
commit = script.run('git', 'rev-parse', 'HEAD',
|
||||
|
@ -38,8 +36,7 @@ def test_get_refs_should_return_branch_name_and_commit_pair():
|
|||
assert result['branch0.1'] == commit, result
|
||||
|
||||
|
||||
def test_get_refs_should_ignore_no_branch():
|
||||
script = reset_env()
|
||||
def test_get_refs_should_ignore_no_branch(script):
|
||||
version_pkg_path = _create_test_package(script)
|
||||
script.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
|
||||
commit = script.run('git', 'rev-parse', 'HEAD',
|
||||
|
@ -82,16 +79,14 @@ def test_check_rev_options_should_handle_ambiguous_commit(get_refs_mock):
|
|||
|
||||
# TODO(pnasrat) fix all helpers to do right things with paths on windows.
|
||||
@pytest.mark.skipif("sys.platform == 'win32'")
|
||||
def test_check_submodule_addition():
|
||||
def test_check_submodule_addition(script):
|
||||
"""
|
||||
Submodules are pulled in on install and updated on upgrade.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
module_path, submodule_path = _create_test_package_with_submodule(script)
|
||||
|
||||
install_result = script.pip('install', '-e', 'git+'+module_path+'#egg=version_pkg')
|
||||
assert '.virtualenv/src/version-pkg/testpkg/static/testfile' in install_result.files_created
|
||||
assert script.venv/'src/version-pkg/testpkg/static/testfile' in install_result.files_created
|
||||
|
||||
_change_test_package_submodule(script, submodule_path)
|
||||
_pull_in_submodule_changes_to_module(script, module_path)
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
from mock import patch
|
||||
from pip.vcs.subversion import Subversion
|
||||
from tests.lib import reset_env
|
||||
|
||||
|
||||
@patch('pip.vcs.subversion.call_subprocess')
|
||||
def test_obtain_should_recognize_auth_info_in_url(call_subprocess_mock):
|
||||
env = reset_env()
|
||||
def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script):
|
||||
svn = Subversion(url='svn+http://username:password@svn.example.com/')
|
||||
svn.obtain(env.scratch_path/'test')
|
||||
svn.obtain(script.scratch_path/'test')
|
||||
call_subprocess_mock.assert_called_with([
|
||||
svn.cmd, 'checkout', '-q', '--username', 'username', '--password', 'password',
|
||||
'http://username:password@svn.example.com/', env.scratch_path/'test'])
|
||||
'http://username:password@svn.example.com/', script.scratch_path/'test'])
|
||||
|
||||
|
||||
@patch('pip.vcs.subversion.call_subprocess')
|
||||
def test_export_should_recognize_auth_info_in_url(call_subprocess_mock):
|
||||
env = reset_env()
|
||||
def test_export_should_recognize_auth_info_url(call_subprocess_mock, script):
|
||||
svn = Subversion(url='svn+http://username:password@svn.example.com/')
|
||||
svn.export(env.scratch_path/'test')
|
||||
svn.export(script.scratch_path/'test')
|
||||
assert call_subprocess_mock.call_args[0] == ([
|
||||
svn.cmd, 'export', '--username', 'username', '--password', 'password',
|
||||
'http://username:password@svn.example.com/', env.scratch_path/'test'],)
|
||||
'http://username:password@svn.example.com/', script.scratch_path/'test'],)
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
from os.path import abspath, join
|
||||
|
||||
from tests.lib import tests_data, reset_env, find_links
|
||||
from tests.lib import tests_data, find_links
|
||||
from tests.lib.path import Path
|
||||
|
||||
|
||||
def test_install_from_wheel():
|
||||
def test_install_from_wheel(script):
|
||||
"""
|
||||
Test installing from a wheel.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'simple.dist', '--use-wheel',
|
||||
'--no-index', '--find-links='+find_links,
|
||||
expect_error=False)
|
||||
|
@ -18,11 +17,10 @@ def test_install_from_wheel():
|
|||
result.stdout)
|
||||
|
||||
|
||||
def test_install_from_wheel_with_extras():
|
||||
def test_install_from_wheel_with_extras(script):
|
||||
"""
|
||||
Test installing from a wheel with extras.
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'complex-dist[simple]', '--use-wheel',
|
||||
'--no-index', '--find-links='+find_links,
|
||||
expect_error=False)
|
||||
|
@ -36,11 +34,10 @@ def test_install_from_wheel_with_extras():
|
|||
result.stdout)
|
||||
|
||||
|
||||
def test_install_from_wheel_file():
|
||||
def test_install_from_wheel_file(script):
|
||||
"""
|
||||
Test installing directly from a wheel file.
|
||||
"""
|
||||
script = reset_env()
|
||||
package = abspath(join(tests_data,
|
||||
'packages',
|
||||
'headers.dist-0.1-py2.py3-none-any.whl'))
|
||||
|
@ -51,11 +48,10 @@ def test_install_from_wheel_file():
|
|||
result.stdout)
|
||||
|
||||
|
||||
def test_install_wheel_with_target():
|
||||
def test_install_wheel_with_target(script):
|
||||
"""
|
||||
Test installing a wheel using pip install --target
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
target_dir = script.scratch_path/'target'
|
||||
result = script.pip('install', 'simple.dist==0.1', '-t', target_dir, '--use-wheel',
|
||||
|
@ -63,12 +59,11 @@ def test_install_wheel_with_target():
|
|||
assert Path('scratch')/'target'/'simpledist' in result.files_created, str(result)
|
||||
|
||||
|
||||
def test_install_from_wheel_installs_deps():
|
||||
def test_install_from_wheel_installs_deps(script):
|
||||
"""
|
||||
Test can install dependencies of wheels
|
||||
"""
|
||||
# 'requires_source' depends on the 'source' project
|
||||
script = reset_env()
|
||||
package = abspath(join(tests_data,
|
||||
'packages',
|
||||
'requires_source-1.0-py2.py3-none-any.whl'))
|
||||
|
@ -76,12 +71,11 @@ def test_install_from_wheel_installs_deps():
|
|||
result.assert_installed('source', editable=False)
|
||||
|
||||
|
||||
def test_install_from_wheel_no_deps():
|
||||
def test_install_from_wheel_no_deps(script):
|
||||
"""
|
||||
Test --no-deps works with wheel installs
|
||||
"""
|
||||
# 'requires_source' depends on the 'source' project
|
||||
script = reset_env()
|
||||
package = abspath(join(tests_data,
|
||||
'packages',
|
||||
'requires_source-1.0-py2.py3-none-any.whl'))
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
import os
|
||||
import re
|
||||
import textwrap
|
||||
from tests.lib import pyversion, reset_env, path_to_url, tests_data, find_links
|
||||
from tests.lib import find_links
|
||||
from tests.lib.local_repos import local_checkout
|
||||
|
||||
|
||||
def test_list_command():
|
||||
def test_list_command(script):
|
||||
"""
|
||||
Test default behavior of list command.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple==1.0', 'simple2==3.0')
|
||||
result = script.pip('list')
|
||||
assert 'simple (1.0)' in result.stdout, str(result)
|
||||
assert 'simple2 (3.0)' in result.stdout, str(result)
|
||||
|
||||
|
||||
def test_local_flag():
|
||||
def test_local_flag(script):
|
||||
"""
|
||||
Test the behavior of --local flag in the list command
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple==1.0')
|
||||
result = script.pip('list', '--local')
|
||||
assert 'simple (1.0)' in result.stdout
|
||||
|
||||
|
||||
def test_uptodate_flag():
|
||||
def test_uptodate_flag(script):
|
||||
"""
|
||||
Test the behavior of --uptodate flag in the list command
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple==1.0', 'simple2==3.0')
|
||||
script.pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
||||
result = script.pip('list', '-f', find_links, '--no-index', '--uptodate')
|
||||
|
@ -42,12 +39,11 @@ def test_uptodate_flag():
|
|||
assert 'simple2 (3.0)' in result.stdout, str(result)
|
||||
|
||||
|
||||
def test_outdated_flag():
|
||||
def test_outdated_flag(script):
|
||||
"""
|
||||
Test the behavior of --outdated flag in the list command
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple==1.0', 'simple2==3.0')
|
||||
script.pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
||||
result = script.pip('list', '-f', find_links, '--no-index', '--outdated')
|
||||
|
@ -56,11 +52,10 @@ def test_outdated_flag():
|
|||
assert 'simple2' not in result.stdout, str(result) #3.0 is latest
|
||||
|
||||
|
||||
def test_editables_flag():
|
||||
def test_editables_flag(script):
|
||||
"""
|
||||
Test the behavior of --editables flag in the list command
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip('install', '-f', find_links, '--no-index', 'simple==1.0')
|
||||
result = script.pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
||||
result = script.pip('list', '--editable')
|
||||
|
|
|
@ -7,7 +7,7 @@ from pip.status_codes import NO_MATCHES_FOUND, SUCCESS
|
|||
from pip.backwardcompat import xmlrpclib, b
|
||||
from pip.baseparser import create_main_parser
|
||||
from mock import Mock
|
||||
from tests.lib import reset_env, pyversion
|
||||
from tests.lib import pyversion
|
||||
|
||||
|
||||
if pyversion >= '3':
|
||||
|
@ -54,32 +54,29 @@ def test_invalid_pypi_transformation():
|
|||
assert transform_hits(pypi_hits) == expected
|
||||
|
||||
|
||||
def test_search():
|
||||
def test_search(script):
|
||||
"""
|
||||
End to end test of search command.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
output = script.pip('search', 'pip')
|
||||
assert 'A tool for installing and managing Python packages' in output.stdout
|
||||
|
||||
|
||||
def test_multiple_search():
|
||||
def test_multiple_search(script):
|
||||
"""
|
||||
Test searching for multiple packages at once.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
output = script.pip('search', 'pip', 'INITools')
|
||||
assert 'A tool for installing and managing Python packages' in output.stdout
|
||||
assert 'Tools for parsing and using INI-style files' in output.stdout
|
||||
|
||||
|
||||
def test_search_missing_argument():
|
||||
def test_search_missing_argument(script):
|
||||
"""
|
||||
Test missing required argument for search
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('search', expect_error=True)
|
||||
assert 'ERROR: Missing required argument (search query).' in result.stdout
|
||||
|
||||
|
@ -106,19 +103,17 @@ def test_run_method_should_return_no_matches_found_when_does_not_find_packages()
|
|||
assert status == NO_MATCHES_FOUND, status
|
||||
|
||||
|
||||
def test_search_should_exit_status_code_zero_when_find_packages():
|
||||
def test_search_should_exit_status_code_zero_when_find_packages(script):
|
||||
"""
|
||||
Test search exit status code for package found
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('search', 'pip')
|
||||
assert result.returncode == SUCCESS
|
||||
|
||||
|
||||
def test_search_exit_status_code_when_finds_no_package():
|
||||
def test_search_exit_status_code_when_finds_no_package(script):
|
||||
"""
|
||||
Test search exit status code for no matches
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('search', 'non-existant-package', expect_error=True)
|
||||
assert result.returncode == NO_MATCHES_FOUND, result.returncode
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
import re
|
||||
from pip import __version__
|
||||
from pip.commands.show import search_packages_info
|
||||
from tests.lib import reset_env
|
||||
|
||||
|
||||
def test_show():
|
||||
def test_show(script):
|
||||
"""
|
||||
Test end to end test for show command.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('show', 'pip')
|
||||
lines = result.stdout.split('\n')
|
||||
assert len(lines) == 6
|
||||
|
@ -20,13 +17,11 @@ def test_show():
|
|||
assert lines[4] == 'Requires: '
|
||||
|
||||
|
||||
def test_show_with_files_not_found():
|
||||
def test_show_with_files_not_found(script):
|
||||
"""
|
||||
Test for show command with installed files listing enabled and
|
||||
installed-files.txt not found.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('show', '-f', 'pip')
|
||||
lines = result.stdout.split('\n')
|
||||
assert len(lines) == 8
|
||||
|
@ -39,23 +34,19 @@ def test_show_with_files_not_found():
|
|||
assert lines[6] == 'Cannot locate installed-files.txt', lines[5]
|
||||
|
||||
|
||||
def test_show_with_all_files():
|
||||
def test_show_with_all_files(script):
|
||||
"""
|
||||
Test listing all files in the show command.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'initools==0.2')
|
||||
result = script.pip('show', '--files', 'initools')
|
||||
assert re.search(r"Files:\n( .+\n)+", result.stdout)
|
||||
|
||||
|
||||
def test_missing_argument():
|
||||
def test_missing_argument(script):
|
||||
"""
|
||||
Test show command with no arguments.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('show')
|
||||
assert 'ERROR: Please provide a package name or names.' in result.stdout
|
||||
|
||||
|
|
|
@ -6,18 +6,17 @@ import sys
|
|||
from os.path import join, abspath, normpath
|
||||
from tempfile import mkdtemp
|
||||
from mock import patch
|
||||
from tests.lib import tests_data, reset_env, assert_all_changes, pyversion
|
||||
from tests.lib import tests_data, assert_all_changes, pyversion
|
||||
from tests.lib.local_repos import local_repo, local_checkout
|
||||
|
||||
from pip.util import rmtree
|
||||
|
||||
|
||||
def test_simple_uninstall():
|
||||
def test_simple_uninstall(script):
|
||||
"""
|
||||
Test simple install and uninstall.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'INITools==0.2')
|
||||
assert join(script.site_packages, 'initools') in result.files_created, sorted(result.files_created.keys())
|
||||
#the import forces the generation of __pycache__ if the version of python supports it
|
||||
|
@ -26,12 +25,11 @@ def test_simple_uninstall():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_with_scripts():
|
||||
def test_uninstall_with_scripts(script):
|
||||
"""
|
||||
Uninstall an easy_installed package with scripts.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.run('easy_install', 'PyLogo', expect_stderr=True)
|
||||
easy_install_pth = script.site_packages/ 'easy-install.pth'
|
||||
pylogo = sys.platform == 'win32' and 'pylogo' or 'PyLogo'
|
||||
|
@ -40,12 +38,11 @@ def test_uninstall_with_scripts():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_easy_install_after_import():
|
||||
def test_uninstall_easy_install_after_import(script):
|
||||
"""
|
||||
Uninstall an easy_installed package after it's been imported
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.run('easy_install', 'INITools==0.2', expect_stderr=True)
|
||||
#the import forces the generation of __pycache__ if the version of python supports it
|
||||
script.run('python', '-c', "import initools")
|
||||
|
@ -53,13 +50,12 @@ def test_uninstall_easy_install_after_import():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_namespace_package():
|
||||
def test_uninstall_namespace_package(script):
|
||||
"""
|
||||
Uninstall a distribution with a namespace package without clobbering
|
||||
the namespace and everything in it.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', 'pd.requires==0.0.3', expect_error=True)
|
||||
assert join(script.site_packages, 'pd') in result.files_created, sorted(result.files_created.keys())
|
||||
result2 = script.pip('uninstall', 'pd.find', '-y', expect_error=True)
|
||||
|
@ -67,7 +63,7 @@ def test_uninstall_namespace_package():
|
|||
assert join(script.site_packages, 'pd', 'find') in result2.files_deleted, sorted(result2.files_deleted.keys())
|
||||
|
||||
|
||||
def test_uninstall_overlapping_package():
|
||||
def test_uninstall_overlapping_package(script):
|
||||
"""
|
||||
Uninstalling a distribution that adds modules to a pre-existing package
|
||||
should only remove those added modules, not the rest of the existing
|
||||
|
@ -77,7 +73,6 @@ def test_uninstall_overlapping_package():
|
|||
"""
|
||||
parent_pkg = abspath(join(tests_data, 'packages', 'parent-0.1.tar.gz'))
|
||||
child_pkg = abspath(join(tests_data, 'packages', 'child-0.1.tar.gz'))
|
||||
script = reset_env()
|
||||
result1 = script.pip('install', parent_pkg, expect_error=False)
|
||||
assert join(script.site_packages, 'parent') in result1.files_created, sorted(result1.files_created.keys())
|
||||
result2 = script.pip('install', child_pkg, expect_error=False)
|
||||
|
@ -94,12 +89,10 @@ def test_uninstall_overlapping_package():
|
|||
assert_all_changes(result2, result3, [])
|
||||
|
||||
|
||||
def test_uninstall_console_scripts():
|
||||
def test_uninstall_console_scripts(script):
|
||||
"""
|
||||
Test uninstalling a package with more files (console_script entry points, extra directories).
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
args = ['install']
|
||||
args.append('discover')
|
||||
result = script.pip(*args, **{"expect_error": True})
|
||||
|
@ -108,12 +101,10 @@ def test_uninstall_console_scripts():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_easy_installed_console_scripts():
|
||||
def test_uninstall_easy_installed_console_scripts(script):
|
||||
"""
|
||||
Test uninstalling package with console_scripts that is easy_installed.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
args = ['easy_install']
|
||||
args.append('discover')
|
||||
result = script.run(*args, **{"expect_stderr": True})
|
||||
|
@ -122,12 +113,10 @@ def test_uninstall_easy_installed_console_scripts():
|
|||
assert_all_changes(result, result2, [script.venv/'build', 'cache'])
|
||||
|
||||
|
||||
def test_uninstall_editable_from_svn():
|
||||
def test_uninstall_editable_from_svn(script):
|
||||
"""
|
||||
Test uninstalling an editable installation from svn.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('install', '-e', '%s#egg=initools-dev' %
|
||||
local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
|
||||
result.assert_installed('INITools')
|
||||
|
@ -136,7 +125,7 @@ def test_uninstall_editable_from_svn():
|
|||
assert_all_changes(result, result2, [script.venv/'src', script.venv/'build'])
|
||||
|
||||
|
||||
def test_uninstall_editable_with_source_outside_venv():
|
||||
def test_uninstall_editable_with_source_outside_venv(script):
|
||||
"""
|
||||
Test uninstalling editable install from existing source outside the venv.
|
||||
|
||||
|
@ -144,13 +133,12 @@ def test_uninstall_editable_with_source_outside_venv():
|
|||
try:
|
||||
temp = mkdtemp()
|
||||
tmpdir = join(temp, 'virtualenv')
|
||||
_test_uninstall_editable_with_source_outside_venv(tmpdir)
|
||||
_test_uninstall_editable_with_source_outside_venv(script, tmpdir)
|
||||
finally:
|
||||
rmtree(temp)
|
||||
|
||||
|
||||
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
|
||||
script = reset_env()
|
||||
def _test_uninstall_editable_with_source_outside_venv(script, tmpdir):
|
||||
result = script.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv'), tmpdir)
|
||||
result2 = script.pip('install', '-e', tmpdir)
|
||||
assert (join(script.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys())
|
||||
|
@ -158,12 +146,11 @@ def _test_uninstall_editable_with_source_outside_venv(tmpdir):
|
|||
assert_all_changes(result, result3, [script.venv/'build'])
|
||||
|
||||
|
||||
def test_uninstall_from_reqs_file():
|
||||
def test_uninstall_from_reqs_file(script):
|
||||
"""
|
||||
Test uninstall from a requirements file.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""\
|
||||
-e %s#egg=initools-dev
|
||||
# and something else to test out:
|
||||
|
@ -185,12 +172,11 @@ def test_uninstall_from_reqs_file():
|
|||
result, result2, [script.venv/'build', script.venv/'src', script.scratch/'test-req.txt'])
|
||||
|
||||
|
||||
def test_uninstall_as_egg():
|
||||
def test_uninstall_as_egg(script):
|
||||
"""
|
||||
Test uninstall package installed as egg.
|
||||
|
||||
"""
|
||||
script = reset_env()
|
||||
to_install = abspath(join(tests_data, 'packages', 'FSPkg'))
|
||||
result = script.pip('install', to_install, '--egg', expect_error=False)
|
||||
fspkg_folder = script.site_packages/'fspkg'
|
||||
|
|
|
@ -9,22 +9,21 @@ from pip import wheel
|
|||
from pip.download import path_to_url as path_to_url_d
|
||||
from pip.locations import write_delete_marker_file
|
||||
from pip.status_codes import PREVIOUS_BUILD_DIR_ERROR
|
||||
from tests.lib import tests_data, reset_env, pyversion_nodot, path_to_url, find_links
|
||||
from tests.lib import tests_data, pyversion_nodot, path_to_url, find_links
|
||||
|
||||
|
||||
def test_pip_wheel_fails_without_wheel():
|
||||
def test_pip_wheel_fails_without_wheel(script):
|
||||
"""
|
||||
Test 'pip wheel' fails without wheel
|
||||
"""
|
||||
script = reset_env()
|
||||
result = script.pip('wheel', '--no-index', '-f', find_links, 'simple==3.0', expect_error=True)
|
||||
assert "'pip wheel' requires bdist_wheel" in result.stdout
|
||||
|
||||
def test_pip_wheel_success():
|
||||
|
||||
def test_pip_wheel_success(script):
|
||||
"""
|
||||
Test 'pip wheel' success.
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
result = script.pip('wheel', '--no-index', '-f', find_links, 'simple==3.0')
|
||||
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
|
||||
|
@ -33,11 +32,10 @@ def test_pip_wheel_success():
|
|||
assert "Successfully built simple" in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_pip_wheel_fail():
|
||||
def test_pip_wheel_fail(script):
|
||||
"""
|
||||
Test 'pip wheel' failure.
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
result = script.pip('wheel', '--no-index', '-f', find_links, 'wheelbroken==0.1')
|
||||
wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot
|
||||
|
@ -47,11 +45,10 @@ def test_pip_wheel_fail():
|
|||
assert "Failed to build wheelbroken" in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_pip_wheel_ignore_wheels_editables():
|
||||
def test_pip_wheel_ignore_wheels_editables(script):
|
||||
"""
|
||||
Test 'pip wheel' ignores editables and *.whl files in requirements
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
|
||||
local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links
|
||||
|
@ -75,23 +72,21 @@ def test_pip_wheel_ignore_wheels_editables():
|
|||
assert ignore_editable in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_no_clean_option_blocks_cleaning_after_wheel():
|
||||
def test_no_clean_option_blocks_cleaning_after_wheel(script):
|
||||
"""
|
||||
Test --no-clean option blocks cleaning after wheel build
|
||||
"""
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
result = script.pip('wheel', '--no-clean', '--no-index', '--find-links=%s' % find_links, 'simple')
|
||||
build = script.venv_path/'build'/'simple'
|
||||
assert exists(build), "build/simple should still exist %s" % str(result)
|
||||
|
||||
|
||||
def test_pip_wheel_source_deps():
|
||||
def test_pip_wheel_source_deps(script):
|
||||
"""
|
||||
Test 'pip wheel --use-wheel' finds and builds source archive dependencies of wheels
|
||||
"""
|
||||
# 'requires_source' is a wheel that depends on the 'source' project
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
result = script.pip('wheel', '--use-wheel', '--no-index', '-f', find_links, 'requires_source')
|
||||
wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot
|
||||
|
@ -100,10 +95,9 @@ def test_pip_wheel_source_deps():
|
|||
assert "Successfully built source" in result.stdout, result.stdout
|
||||
|
||||
|
||||
def test_pip_wheel_fail_cause_of_previous_build_dir():
|
||||
def test_pip_wheel_fail_cause_of_previous_build_dir(script):
|
||||
"""Test when 'pip wheel' tries to install a package that has a previous build directory"""
|
||||
|
||||
script = reset_env()
|
||||
script.pip_install_local('wheel')
|
||||
|
||||
# Given that I have a previous build dir of the `simple` package
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
"""Test the test support."""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import filecmp
|
||||
import re
|
||||
from os.path import join, isdir
|
||||
|
||||
from tests.lib import reset_env, src_folder
|
||||
from tests.lib import src_folder
|
||||
|
||||
|
||||
def test_tmp_dir_exists_in_env():
|
||||
def test_tmp_dir_exists_in_env(script):
|
||||
"""
|
||||
Test that $TMPDIR == env.temp_path and path exists and env.assert_no_temp() passes (in fast env)
|
||||
"""
|
||||
#need these tests to ensure the assert_no_temp feature of scripttest is working
|
||||
env = reset_env()
|
||||
env.assert_no_temp() #this fails if env.tmp_path doesn't exist
|
||||
assert env.environ['TMPDIR'] == env.temp_path
|
||||
assert isdir(env.temp_path)
|
||||
script.assert_no_temp() #this fails if env.tmp_path doesn't exist
|
||||
assert script.environ['TMPDIR'] == script.temp_path
|
||||
assert isdir(script.temp_path)
|
||||
|
||||
|
||||
def test_correct_pip_version():
|
||||
def test_correct_pip_version(script):
|
||||
"""
|
||||
Check we are running proper version of pip in run_pip.
|
||||
"""
|
||||
script = reset_env()
|
||||
|
||||
# output is like:
|
||||
# pip PIPVERSION from PIPDIRECTORY (python PYVERSION)
|
||||
result = script.pip('--version')
|
||||
|
@ -41,4 +40,3 @@ def test_correct_pip_version():
|
|||
# maintenance
|
||||
mismatch_py = [x for x in diffs.left_only + diffs.right_only + diffs.diff_files if x.endswith('.py')]
|
||||
assert not mismatch_py, 'mismatched source files in %r and %r: %r'% (pip_folder, pip_folder_outputed, mismatch_py)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from mock import Mock, patch
|
|||
from pip.exceptions import BadCommand
|
||||
from pip.util import (egg_link_path, Inf, get_installed_distributions,
|
||||
find_command, untar_file, unzip_file)
|
||||
from tests.lib import reset_env, tests_data
|
||||
from tests.lib import tests_data
|
||||
|
||||
|
||||
class Tests_EgglinkPath:
|
||||
|
@ -203,16 +203,12 @@ class Tests_get_installed_distributions:
|
|||
assert len(dists) == 3
|
||||
|
||||
|
||||
def test_find_command_folder_in_path(monkeypatch):
|
||||
def test_find_command_folder_in_path(script):
|
||||
"""
|
||||
If a folder named e.g. 'git' is in PATH, and find_command is looking for
|
||||
the 'git' executable, it should not match the folder, but rather keep
|
||||
looking.
|
||||
"""
|
||||
# Why in the world is this needed?
|
||||
monkeypatch.setattr(shutil, "_use_fd_functions", False, raising=False)
|
||||
|
||||
script = reset_env()
|
||||
script.scratch_path.join("path_one").mkdir()
|
||||
path_one = script.scratch_path/'path_one'
|
||||
path_one.join("foo").mkdir()
|
||||
|
|
Loading…
Reference in New Issue