本文整理汇总了Python中tests.test_pip.write_file函数的典型用法代码示例。如果您正苦于以下问题:Python write_file函数的具体用法?Python write_file怎么用?Python write_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _change_test_package_submodule
def _change_test_package_submodule(env, submodule_path):
write_file(submodule_path/'testfile', 'this is a changed file')
write_file(submodule_path/'testfile2', 'this is an added file')
env.run('git', 'add', '.', cwd=submodule_path)
env.run('git', 'commit', '-q',
'--author', 'Pip <[email protected]>',
'-am', 'submodule change', cwd=submodule_path)
开发者ID:AndreaCrotti,项目名称:pip,代码行数:7,代码来源:git_submodule_helpers.py
示例2: test_upgrade_from_reqs_file
def test_upgrade_from_reqs_file():
"""
Upgrade from a requirements file.
"""
env = reset_env()
write_file(
"test-req.txt",
textwrap.dedent(
"""\
PyLogo<0.4
# and something else to test out:
INITools==0.3
"""
),
)
install_result = run_pip("install", "-r", env.scratch_path / "test-req.txt")
write_file(
"test-req.txt",
textwrap.dedent(
"""\
PyLogo
# and something else to test out:
INITools
"""
),
)
run_pip("install", "--upgrade", "-r", env.scratch_path / "test-req.txt")
uninstall_result = run_pip("uninstall", "-r", env.scratch_path / "test-req.txt", "-y")
assert_all_changes(install_result, uninstall_result, [env.venv / "build", "cache", env.scratch / "test-req.txt"])
开发者ID:none-da,项目名称:pip,代码行数:30,代码来源:test_upgrade.py
示例3: test_download_should_skip_existing_files
def test_download_should_skip_existing_files():
"""
It should not download files already existing in the scratch dir
"""
env = reset_env()
write_file('test-req.txt', textwrap.dedent("""
INITools==0.1
"""))
result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
assert env.site_packages/ 'initools' not in result.files_created
# adding second package to test-req.txt
write_file('test-req.txt', textwrap.dedent("""
INITools==0.1
python-openid==2.2.5
"""))
# only the second package should be downloaded
result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
openid_tarball_prefix = str(Path('scratch')/ 'python-openid-')
assert any(path.startswith(openid_tarball_prefix) for path in result.files_created)
assert Path('scratch')/ 'INITools-0.1.tar.gz' not in result.files_created
assert env.site_packages/ 'initools' not in result.files_created
assert env.site_packages/ 'openid' not in result.files_created
开发者ID:AndreaCrotti,项目名称:pip,代码行数:27,代码来源:test_download.py
示例4: test_cleanup_after_create_bundle
def test_cleanup_after_create_bundle():
"""
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
"""
env = reset_env()
# Install an editable to create a src/ dir.
args = ['install']
args.extend(['-e',
'%s#egg=pip-test-package' %
local_checkout('git+http://github.com/pypa/pip-test-package.git')])
run_pip(*args)
build = env.venv_path/"build"
src = env.venv_path/"src"
assert not exists(build), "build/ dir still exists: %s" % build
assert exists(src), "expected src/ dir doesn't exist: %s" % src
# Make the bundle.
fspkg = 'file://%s/FSPkg' %join(here, 'packages')
pkg_lines = textwrap.dedent('''\
-e %s
-e %s#egg=initools-dev
pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
write_file('bundle-req.txt', pkg_lines)
run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
build_bundle = env.scratch_path/"build-bundle"
src_bundle = env.scratch_path/"src-bundle"
assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle
# Make sure previously created src/ from editable still exists
assert exists(src), "expected src dir doesn't exist: %s" % src
开发者ID:michaeta,项目名称:pip,代码行数:32,代码来源:test_cleanup.py
示例5: 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'])
开发者ID:AndreaCrotti,项目名称:pip,代码行数:25,代码来源:test_uninstall.py
示例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)
开发者ID:OldBao,项目名称:pip,代码行数:34,代码来源:test_freeze.py
示例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
开发者ID:MatthewMaker,项目名称:pip,代码行数:33,代码来源:test_config.py
示例8: test_schema_check_in_requirements_file
def test_schema_check_in_requirements_file():
"""
Test installing from a requirements file with an invalid vcs schema..
"""
env = reset_env()
write_file('file-egg-req.txt', textwrap.dedent("""\
git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
"""))
assert_raises(AssertionError, run_pip, 'install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
开发者ID:OldBao,项目名称:pip,代码行数:10,代码来源:test_requirements.py
示例9: test_install_folder_using_dot_slash
def test_install_folder_using_dot_slash():
"""
Test installing a folder using pip install ./foldername
"""
env = reset_env()
mkdir("mock")
pkg_path = env.scratch_path / "mock"
write_file("setup.py", mock100_setup_py, pkg_path)
result = run_pip("install", "./mock")
egg_folder = env.site_packages / "mock-100.1-py%s.egg-info" % pyversion
assert egg_folder in result.files_created, str(result)
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:11,代码来源:test_basic.py
示例10: test_install_folder_using_slash_in_the_end
def test_install_folder_using_slash_in_the_end():
r"""
Test installing a folder using pip install foldername/ or foldername\
"""
env = reset_env()
mkdir('mock')
pkg_path = env.scratch_path/'mock'
write_file('setup.py', mock100_setup_py, pkg_path)
result = run_pip('install', 'mock' + os.path.sep)
egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
assert egg_folder in result.files_created, str(result)
开发者ID:saxix,项目名称:pip,代码行数:11,代码来源:test_basic.py
示例11: test_single_download_from_requirements_file
def test_single_download_from_requirements_file():
"""
It should support download (in the scratch path) from PyPi from a requirements file
"""
env = reset_env()
write_file('test-req.txt', textwrap.dedent("""
INITools==0.1
"""))
result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True)
assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created
assert env.site_packages/ 'initools' not in result.files_created
开发者ID:OldBao,项目名称:pip,代码行数:12,代码来源:test_download.py
示例12: test_install_folder_using_relative_path
def test_install_folder_using_relative_path():
"""
Test installing a folder using pip install folder1/folder2
"""
env = reset_env()
mkdir("initools")
mkdir(Path("initools") / "mock")
pkg_path = env.scratch_path / "initools" / "mock"
write_file("setup.py", mock100_setup_py, pkg_path)
result = run_pip("install", Path("initools") / "mock")
egg_folder = env.site_packages / "mock-100.1-py%s.egg-info" % pyversion
assert egg_folder in result.files_created, str(result)
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:12,代码来源:test_basic.py
示例13: test_install_folder_using_relative_path
def test_install_folder_using_relative_path():
"""
Test installing a folder using pip install folder1/folder2
"""
env = reset_env()
mkdir('initools')
mkdir(Path('initools')/'mock')
pkg_path = env.scratch_path/'initools'/'mock'
write_file('setup.py', mock100_setup_py, pkg_path)
result = run_pip('install', Path('initools')/'mock')
egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion
assert egg_folder in result.files_created, str(result)
开发者ID:saxix,项目名称:pip,代码行数:12,代码来源:test_basic.py
示例14: test_relative_requirements_file
def test_relative_requirements_file():
"""
Test installing from a requirements file with a relative path with an egg= definition..
"""
url = path_to_url(os.path.join(here, 'packages', '..', 'packages', 'FSPkg')) + '#egg=FSPkg'
env = reset_env()
write_file('file-egg-req.txt', textwrap.dedent("""\
%s
""" % url))
result = run_pip('install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
assert (env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
assert (env.site_packages/'fspkg') in result.files_created, str(result.stdout)
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:13,代码来源:test_requirements.py
示例15: test_find_command_folder_in_path
def test_find_command_folder_in_path():
"""
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.
"""
env = reset_env()
mkdir('path_one'); path_one = env.scratch_path/'path_one'
mkdir(path_one/'foo')
mkdir('path_two'); path_two = env.scratch_path/'path_two'
write_file(path_two/'foo', '# nothing')
found_path = find_command('foo', map(str, [path_one, path_two]))
assert found_path == path_two/'foo'
开发者ID:PJMODOS,项目名称:pip,代码行数:13,代码来源:test_basic.py
示例16: test_find_command_folder_in_path
def test_find_command_folder_in_path():
"""
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.
"""
env = reset_env()
mkdir("path_one")
path_one = env.scratch_path / "path_one"
mkdir(path_one / "foo")
mkdir("path_two")
path_two = env.scratch_path / "path_two"
write_file(path_two / "foo", "# nothing")
found_path = find_command("foo", map(str, [path_one, path_two]))
assert found_path == path_two / "foo"
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:15,代码来源:test_basic.py
示例17: test_find_links_requirements_file_relative_path
def test_find_links_requirements_file_relative_path():
"""Test find-links as a relative path to a reqs file."""
e = reset_env()
write_file('test-req.txt', textwrap.dedent("""
--no-index
--find-links=../../../packages/
parent==0.1
"""))
result = run_pip(
'install',
'-r',
e.scratch_path / "test-req.txt",
cwd=here)
egg_info_folder = e.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
initools_folder = e.site_packages / 'parent'
assert egg_info_folder in result.files_created, str(result)
assert initools_folder in result.files_created, str(result)
开发者ID:AndreaCrotti,项目名称:pip,代码行数:17,代码来源:test_find_links.py
示例18: test_respect_order_in_requirements_file
def test_respect_order_in_requirements_file():
env = reset_env()
write_file('frameworks-req.txt', textwrap.dedent("""\
bidict
ordereddict
initools
"""))
result = run_pip('install', '-r', env.scratch_path / 'frameworks-req.txt')
downloaded = [line for line in result.stdout.split('\n')
if 'Downloading/unpacking' in line]
assert 'bidict' in downloaded[0], 'First download should ' \
'be "bidict" but was "%s"' % downloaded[0]
assert 'ordereddict' in downloaded[1], 'Second download should ' \
'be "ordereddict" but was "%s"' % downloaded[1]
assert 'initools' in downloaded[2], 'Third download should ' \
'be "initools" but was "%s"' % downloaded[2]
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:17,代码来源:test_requirements.py
示例19: test_requirements_file
def test_requirements_file():
"""
Test installing from a requirements file.
"""
other_lib_name, other_lib_version = 'anyjson', '0.3'
env = reset_env()
write_file('initools-req.txt', textwrap.dedent("""\
INITools==0.2
# and something else to test out:
%s<=%s
""" % (other_lib_name, other_lib_version)))
result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
assert env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created
assert env.site_packages/'initools' in result.files_created
assert result.files_created[env.site_packages/other_lib_name].dir
fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
assert result.files_created[env.site_packages/fn].dir
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:18,代码来源:test_requirements.py
示例20: _test_env_vars_override_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
reset_env(environ)
# 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
# of the config dictionary.
write_file(config_file, textwrap.dedent("""\
[global]
no-index = 1
"""))
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
environ['PIP_NO_INDEX'] = '0'
reset_env(environ)
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
assert "Successfully installed INITools" in result.stdout
开发者ID:AndreaCrotti,项目名称:pip,代码行数:18,代码来源:test_config.py
注:本文中的tests.test_pip.write_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论