本文整理汇总了Python中tests.lib.requirements_file函数的典型用法代码示例。如果您正苦于以下问题:Python requirements_file函数的具体用法?Python requirements_file怎么用?Python requirements_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了requirements_file函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_install_requirements_with_options
def test_install_requirements_with_options(self, tmpdir, finder, session,
options):
global_option = '--dry-run'
install_option = '--prefix=/opt'
content = '''
--only-binary :all:
INITools==2.0 --global-option="{global_option}" \
--install-option "{install_option}"
'''.format(global_option=global_option, install_option=install_option)
with requirements_file(content, tmpdir) as reqs_file:
req = next(parse_requirements(reqs_file.abspath,
finder=finder,
options=options,
session=session))
req.source_dir = os.curdir
with patch.object(subprocess, 'Popen') as popen:
popen.return_value.stdout.readline.return_value = b""
try:
req.install([])
except:
pass
last_call = popen.call_args_list[-1]
args = last_call[0][0]
assert (
0 < args.index(global_option) < args.index('install') <
args.index(install_option)
)
assert options.format_control.no_binary == {':all:'}
assert options.format_control.only_binary == set()
开发者ID:edmorley,项目名称:pip,代码行数:33,代码来源:test_req_file.py
示例2: test_missing_hash_with_require_hashes_in_reqs_file
def test_missing_hash_with_require_hashes_in_reqs_file(self, data, tmpdir):
"""--require-hashes in a requirements file should make its way to the
RequirementSet.
"""
req_set = self.basic_reqset(require_hashes=False)
session = PipSession()
finder = PackageFinder([data.find_links], [], session=session)
command = InstallCommand()
with requirements_file("--require-hashes", tmpdir) as reqs_file:
options, args = command.parse_args(["-r", reqs_file])
command.populate_requirement_set(req_set, args, options, finder, session, command.name, wheel_cache=None)
assert req_set.require_hashes
开发者ID:sbidoul,项目名称:pip,代码行数:12,代码来源:test_req.py
示例3: test_relative_requirements_file
def test_relative_requirements_file(script, data):
"""
Test installing from a requirements file with a relative path. For path
URLs, use an egg= definition.
"""
egg_info_file = (
script.site_packages / 'FSPkg-0.1.dev0-py%s.egg-info' % pyversion
)
egg_link_file = (
script.site_packages / 'FSPkg.egg-link'
)
package_folder = script.site_packages / 'fspkg'
# Compute relative install path to FSPkg from scratch path.
full_rel_path = data.packages.join('FSPkg') - script.scratch_path
full_rel_url = 'file:' + full_rel_path + '#egg=FSPkg'
embedded_rel_path = script.scratch_path.join(full_rel_path)
# For each relative path, install as either editable or not using either
# URLs with egg links or not.
for req_path in (full_rel_path, full_rel_url, embedded_rel_path):
req_path = req_path.replace(os.path.sep, '/')
# Regular install.
with requirements_file(req_path + '\n',
script.scratch_path) as reqs_file:
result = script.pip('install', '-vvv', '-r', reqs_file.name,
cwd=script.scratch_path)
assert egg_info_file in result.files_created, str(result)
assert package_folder in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
# Editable install.
with requirements_file('-e ' + req_path + '\n',
script.scratch_path) as reqs_file:
result = script.pip('install', '-vvv', '-r', reqs_file.name,
cwd=script.scratch_path)
assert egg_link_file in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
开发者ID:jonparrott,项目名称:pip,代码行数:39,代码来源:test_install_reqs.py
示例4: test_hashed_install_failure
def test_hashed_install_failure(script, data, tmpdir):
"""Test that wrong hashes stop installation.
This makes sure prepare_files() is called in the course of installation
and so has the opportunity to halt if hashes are wrong. Checks on various
kinds of hashes are in test_req.py.
"""
with requirements_file('simple2==1.0 --hash=sha256:9336af72ca661e6336eb87b'
'c7de3e8844d853e3848c2b9bbd2e8bf01db88c2c\n',
tmpdir) as reqs_file:
result = script.pip_install_local('-r',
reqs_file.abspath,
expect_error=True)
assert len(result.files_created) == 0
开发者ID:alquerci,项目名称:pip,代码行数:15,代码来源:test_install.py
示例5: test_hashed_install_success
def test_hashed_install_success(script, data, tmpdir):
"""
Test that installing various sorts of requirements with correct hashes
works.
Test file URLs and index packages (which become HTTP URLs behind the
scenes).
"""
file_url = path_to_url(
(data.packages / 'simple-1.0.tar.gz').abspath)
with requirements_file(
'simple2==1.0 --hash=sha256:9336af72ca661e6336eb87bc7de3e8844d853e'
'3848c2b9bbd2e8bf01db88c2c7\n'
'{simple} --hash=sha256:393043e672415891885c9a2a0929b1af95fb866d6c'
'a016b42d2e6ce53619b653'.format(simple=file_url),
tmpdir) as reqs_file:
script.pip_install_local('-r', reqs_file.abspath, expect_error=False)
开发者ID:alquerci,项目名称:pip,代码行数:18,代码来源:test_install.py
注:本文中的tests.lib.requirements_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论