本文整理汇总了Python中tests.test_pip.run_pip函数的典型用法代码示例。如果您正苦于以下问题:Python run_pip函数的具体用法?Python run_pip怎么用?Python run_pip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_pip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_freeze_bazaar_clone
def test_freeze_bazaar_clone():
"""
Test freezing a Bazaar clone.
"""
reset_env()
env = get_env()
result = env.run('bzr', 'checkout', '-r', '174',
local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
'django-wikiapp')
result = env.run('python', 'setup.py', 'develop',
cwd=env.scratch_path/'django-wikiapp')
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
-- stdout: --------------------
-e %[email protected]#egg=django_wikiapp-...
...""" % local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'))
_check_output(result, expected)
result = run_pip('freeze', '-f',
'%s/#egg=django-wikiapp' %
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
-- stdout: --------------------
-f %(repo)s/#egg=django-wikiapp
-e %(repo)[email protected]#egg=django_wikiapp-...
...""" % {'repo':
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')})
_check_output(result, expected)
示例2: test_freeze_with_local_option
def test_freeze_with_local_option():
"""
Test that wsgiref (from global site-packages) is reported normally, but not with --local.
"""
reset_env()
result = run_pip('install', 'initools==0.2')
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
-- stdout: --------------------
INITools==0.2
wsgiref==...
<BLANKLINE>""")
# The following check is broken (see
# http://bitbucket.org/ianb/pip/issue/110). For now we are simply
# neutering this test, but if we can't find a way to fix it,
# this whole function should be removed.
# _check_output(result, expected)
result = run_pip('freeze', '--local', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze --local
-- stdout: --------------------
INITools==0.2
<BLANKLINE>""")
_check_output(result, expected)
示例3: test_freeze_git_clone
def test_freeze_git_clone():
"""
Test freezing a Git clone.
"""
env = reset_env()
result = env.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git'), 'pip-test-package')
result = env.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
cwd=env.scratch_path / 'pip-test-package', expect_stderr=True)
result = env.run('python', 'setup.py', 'develop',
cwd=env.scratch_path / 'pip-test-package')
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
-- stdout: --------------------
...-e %[email protected]#egg=pip_test_package-...
...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git'))
_check_output(result, expected)
result = run_pip('freeze', '-f',
'%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git'),
expect_stderr=True)
expected = textwrap.dedent("""\
Script result: pip freeze -f %(repo)s#egg=pip_test_package
-- stdout: --------------------
-f %(repo)s#egg=pip_test_package...
-e %(repo)[email protected]#egg=pip_test_package-dev
...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git')})
_check_output(result, expected)
示例4: test_freeze_mercurial_clone
def test_freeze_mercurial_clone():
"""
Test freezing a Mercurial clone.
"""
reset_env()
env = get_env()
result = env.run('hg', 'clone',
'-r', '7bc186caa7dc',
local_repo('hg+http://bitbucket.org/jezdez/django-authority'),
'django-authority')
result = env.run('python', 'setup.py', 'develop',
cwd=env.scratch_path/'django-authority', expect_stderr=True)
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
-- stdout: --------------------
-e %[email protected]#egg=django_authority-...
...""" % local_checkout('hg+http://bitbucket.org/jezdez/django-authority'))
_check_output(result, expected)
result = run_pip('freeze', '-f',
'%s#egg=django_authority' % local_checkout('hg+http://bitbucket.org/jezdez/django-authority'),
expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze -f %(repo)s#egg=django_authority
-- stdout: --------------------
-f %(repo)s#egg=django_authority
-e %(repo)[email protected]#egg=django_authority-dev
...""" % {'repo': local_checkout('hg+http://bitbucket.org/jezdez/django-authority')})
_check_output(result, expected)
示例5: test_uninstall_overlapping_package
def test_uninstall_overlapping_package():
"""
Uninstalling a distribution that adds modules to a pre-existing package
should only remove those added modules, not the rest of the existing
package.
See: GitHub issue #355 (pip uninstall removes things it didn't install)
"""
parent_pkg = abspath(join(here, 'packages', 'parent-0.1.tar.gz'))
child_pkg = abspath(join(here, 'packages', 'child-0.1.tar.gz'))
env = reset_env()
result1 = run_pip('install', parent_pkg, expect_error=False)
assert join(env.site_packages, 'parent') in result1.files_created, sorted(result1.files_created.keys())
result2 = run_pip('install', child_pkg, expect_error=False)
assert join(env.site_packages, 'child') in result2.files_created, sorted(result2.files_created.keys())
assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result2.files_created, sorted(result2.files_created.keys())
#the import forces the generation of __pycache__ if the version of python supports it
env.run('python', '-c', "import parent.plugins.child_plugin, child")
result3 = run_pip('uninstall', '-y', 'child', expect_error=False)
assert join(env.site_packages, 'child') in result3.files_deleted, sorted(result3.files_created.keys())
assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result3.files_deleted, sorted(result3.files_deleted.keys())
assert join(env.site_packages, 'parent') not in result3.files_deleted, sorted(result3.files_deleted.keys())
# Additional check: uninstalling 'child' should return things to the
# previous state, without unintended side effects.
assert_all_changes(result2, result3, [])
示例6: test_freeze_with_requirement_option
def test_freeze_with_requirement_option():
"""
Test that new requirements are created correctly with --requirement hints
"""
reset_env()
ignores = textwrap.dedent("""\
# Unchanged requirements below this line
-r ignore.txt
--requirement ignore.txt
-Z ignore
--always-unzip ignore
-f http://ignore
-i http://ignore
--extra-index-url http://ignore
--find-links http://ignore
--index-url http://ignore
""")
write_file('hint.txt', textwrap.dedent("""\
INITools==0.1
NoExist==4.2
""") + ignores)
result = run_pip('install', 'initools==0.2')
result = run_pip('install', 'MarkupSafe')
result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: pip freeze --requirement hint.txt
-- stderr: --------------------
Requirement file contains NoExist==4.2, but that package is not installed
-- stdout: --------------------
INITools==0.2
""") + ignores + "## The following requirements were added by pip --freeze:..."
_check_output(result, expected)
示例7: _test_uninstall_editable_with_source_outside_venv
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
env = reset_env()
result = env.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv'), tmpdir)
result2 = run_pip('install', '-e', tmpdir)
assert (join(env.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys())
result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
assert_all_changes(result, result3, [env.venv/'build'])
示例8: test_no_upgrade_editable_if_prefer_pinned
def test_no_upgrade_editable_if_prefer_pinned():
"""
No upgrade of editable if 1)--prefer-pinned-revision is True and 2) previously installed version is pinned.
"""
reset_env()
local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')
args = ['install',
# older version
'-e', '%[email protected]#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
result.assert_installed('sb-test-package')
args = ['install',
'--prefer-pinned-revision',
# unpinned newer version
'-e', '%s#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
# worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
expected_files_regex = re.compile('[.]git')
worrysome_files_created = [file_path for file_path in result.files_created.keys() if not expected_files_regex.search(file_path)]
assert not worrysome_files_created, 'sb install sb-test-package upgraded when it should not have'
示例9: _test_uninstall_editable_with_source_outside_venv
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
env = reset_env()
result = env.run("git", "clone", local_repo("git+git://github.com/pypa/virtualenv"), tmpdir)
result2 = run_pip("install", "-e", tmpdir)
assert join(env.site_packages, "virtualenv.egg-link") in result2.files_created, list(result2.files_created.keys())
result3 = run_pip("uninstall", "-y", "virtualenv", expect_error=True)
assert_all_changes(result, result3, [env.venv / "build"])
示例10: test_install_user_conflict_in_globalsite_and_usersite
def test_install_user_conflict_in_globalsite_and_usersite(self):
"""
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
# 1) a monkey patch which will make it appear INITools==0.2 is not in in the virtualenv site
# 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
env = reset_env(system_site_packages=True, sitecustomize=patch_dist_in_site_packages)
env.environ["PYTHONPATH"] = env.root_path / env.user_site
result1 = run_pip('install', 'INITools==0.2')
result2 = run_pip('install', '--user', 'INITools==0.3')
result3 = run_pip('install', '--user', 'INITools==0.1')
#usersite has 0.1
egg_info_folder = env.user_site / 'INITools-0.1-py%s.egg-info' % pyversion
initools_v3_file = env.root_path / env.user_site / 'initools' / 'configparser.py' #file only in 0.3
assert egg_info_folder in result3.files_created, str(result3)
assert not isfile(initools_v3_file), initools_v3_file
#site still has 0.2 (can't just look in result1; have to check)
egg_info_folder = env.root_path / env.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
initools_folder = env.root_path / env.site_packages / 'initools'
assert isdir(egg_info_folder)
assert isdir(initools_folder)
示例11: _test_config_file_override_stack
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
reset_env(environ)
write_file(
config_file,
textwrap.dedent(
"""\
[global]
index-url = http://download.zope.org/ppix
"""
),
)
result = run_pip("install", "-vvv", "INITools", expect_error=True)
assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
reset_env(environ)
write_file(
config_file,
textwrap.dedent(
"""\
[global]
index-url = http://download.zope.org/ppix
[install]
index-url = http://pypi.appspot.com/
"""
),
)
result = run_pip("install", "-vvv", "INITools", expect_error=True)
assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
result = run_pip("install", "-vvv", "--index-url", "http://pypi.python.org/simple", "INITools", expect_error=True)
assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
示例12: test_no_upgrade_editable_if_uncommitted_change
def test_no_upgrade_editable_if_uncommitted_change():
"""
No upgrade of editable if there are uncommitted local changes.
"""
env = reset_env()
local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')
args = ['install',
# older version
'-e', '%[email protected]#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
result.assert_installed('sb-test-package')
# Make modification to an existing file
with open(os.path.join(env.venv_path, 'src/sb-test-package', 'requirements.txt'), 'a') as file:
file.write('local modification!')
# Attempt to install a new version
args = ['install',
# unpinned newer version
'-e', '%s#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
assert versions.__InstallationErrorMessage__ in result.stdout
示例13: test_upgrade_editable_if_no_prefer_pinned
def test_upgrade_editable_if_no_prefer_pinned():
"""
Upgrade editable if 1)--prefer-pinned-revision is False (default) and 2) previously installed version is pinned and not the latest version.
"""
reset_env()
local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')
args = ['install',
# older version
'-e', '%[email protected]#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
result.assert_installed('sb-test-package')
args = ['install',
# unpinned newer version
'-e', '%s#egg=sb-test-package' % local_url]
result = run_pip(*args, **{"expect_error": True})
# worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
expected_files_regex = re.compile('[.]git')
new_files_created = [file_path for file_path in result.files_created.keys() if not expected_files_regex.search(file_path)]
# new_files_created should contain a file that appears in versions >=0.2.1, but not in 0.2.2
assert new_files_created, 'sb install sb-test-package did not upgrade when it should have'
示例14: test_freeze_git_clone
def test_freeze_git_clone():
"""
Test freezing a Git clone.
"""
env = reset_env()
result = env.run('git', 'clone', local_repo('git+http://github.com/jezdez/django-pagination.git'), 'django-pagination')
result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8',
cwd=env.scratch_path/'django-pagination', expect_stderr=True)
result = env.run('python', 'setup.py', 'develop',
cwd=env.scratch_path / 'django-pagination')
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze
-- stdout: --------------------
-e %[email protected]#egg=django_pagination-...
...""" % local_checkout('git+http://github.com/jezdez/django-pagination.git'))
_check_output(result, expected)
result = run_pip('freeze', '-f',
'%s#egg=django_pagination' % local_checkout('git+http://github.com/jezdez/django-pagination.git'),
expect_stderr=True)
expected = textwrap.dedent("""\
Script result: pip freeze -f %(repo)s#egg=django_pagination
-- stdout: --------------------
-f %(repo)s#egg=django_pagination
-e %(repo)[email protected]#egg=django_pagination-dev
...""" % {'repo': local_checkout('git+http://github.com/jezdez/django-pagination.git')})
_check_output(result, expected)
示例15: test_uninstall_from_reqs_file
def test_uninstall_from_reqs_file():
"""
Test uninstall from a requirements file.
"""
env = reset_env()
write_file('test-req.txt', textwrap.dedent("""\
-e %s#egg=initools-dev
# and something else to test out:
PyLogo<0.4
""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
result = run_pip('install', '-r', 'test-req.txt')
write_file('test-req.txt', textwrap.dedent("""\
# -f, -i, and --extra-index-url should all be ignored by uninstall
-f http://www.example.com
-i http://www.example.com
--extra-index-url http://www.example.com
-e %s#egg=initools-dev
# and something else to test out:
PyLogo<0.4
""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
assert_all_changes(
result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])