本文整理汇总了Python中tests.test_pip.reset_env函数的典型用法代码示例。如果您正苦于以下问题:Python reset_env函数的具体用法?Python reset_env怎么用?Python reset_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset_env函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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'
示例2: 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)
示例3: 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)
示例4: test_help_command_should_exit_status_error_when_command_does_not_exist
def test_help_command_should_exit_status_error_when_command_does_not_exist():
"""
Test `help` command for non-existing command
"""
reset_env()
result = run_pip('help', 'mycommand', expect_error=True)
assert result.returncode == ERROR
示例5: 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)
示例6: test_install_with_pax_header
def test_install_with_pax_header():
"""
test installing from a tarball with pax header for python<2.6
"""
reset_env()
run_from = abspath(join(here, 'packages'))
run_pip('install', 'paxpkg.tar.bz2', cwd=run_from)
示例7: _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
示例8: 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)
示例9: test_help_command_should_exit_status_ok_when_no_command_is_specified
def test_help_command_should_exit_status_ok_when_no_command_is_specified():
"""
Test `help` command for no command
"""
reset_env()
result = run_pip('help')
assert result.returncode == SUCCESS
示例10: test_help_command_should_exit_status_ok_when_command_exists
def test_help_command_should_exit_status_ok_when_command_exists():
"""
Test `help` command for existing command
"""
reset_env()
result = run_pip('help', 'freeze')
assert result.returncode == SUCCESS
示例11: test_freeze_bazaar_clone
def test_freeze_bazaar_clone():
"""
Test freezing a Bazaar clone.
"""
checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')
#bzr internally stores windows drives as uppercase; we'll match that.
checkout_pathC = checkout_path.replace('c:', 'C:')
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-...
...""" % checkout_pathC)
_check_output(result, expected)
result = run_pip('freeze', '-f',
'%s/#egg=django-wikiapp' % checkout_path,
expect_stderr=True)
expected = textwrap.dedent("""\
Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
-- stdout: --------------------
-f %(repo)s/#egg=django-wikiapp
...-e %(repoC)[email protected]#egg=django_wikiapp-...
...""" % {'repoC': checkout_pathC, 'repo': checkout_path})
_check_output(result, expected)
示例12: 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'
示例13: test_install_fails_with_no_ssl_backport
def test_install_fails_with_no_ssl_backport(self):
"""
Test installing w/o ssl backport fails
"""
reset_env(insecure=False)
#expect error because ssl's setup.py is hard coded to install test data to global prefix
result = run_pip('install', 'INITools', expect_error=True)
assert "You don't have an importable ssl module" in result.stdout
示例14: test_search
def test_search():
"""
End to end test of search command.
"""
reset_env()
output = run_pip('search', 'pip')
assert 'pip installs packages' in output.stdout
示例15: test_upgrade_vcs_req_with_dist_found
def test_upgrade_vcs_req_with_dist_found():
"""It can upgrade a VCS requirement that has distributions on the index."""
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/[email protected]58a33fb50499"
run_pip("install", req)
result = run_pip("install", "-U", req)
assert not "pypi.python.org" in result.stdout, result.stdout