本文整理汇总了Python中tests.lib._create_test_package函数的典型用法代码示例。如果您正苦于以下问题:Python _create_test_package函数的具体用法?Python _create_test_package怎么用?Python _create_test_package使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_create_test_package函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_freeze_bazaar_clone
def test_freeze_bazaar_clone(script, tmpdir):
"""
Test freezing a Bazaar clone.
"""
try:
checkout_path = _create_test_package(script, vcs='bazaar')
except OSError as e:
pytest.fail('Invoking `bzr` failed: %s' % e)
result = script.run(
'bzr', 'checkout', checkout_path, 'bzr-package'
)
result = script.run(
'python', 'setup.py', 'develop',
cwd=script.scratch_path / 'bzr-package',
expect_stderr=True,
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
...-e bzr+file://[email protected]#egg=version_pkg
...""")
_check_output(result.stdout, expected)
result = script.pip(
'freeze', '-f',
'%s/#egg=django-wikiapp' % checkout_path,
expect_stderr=True,
)
expected = textwrap.dedent("""\
-f %(repo)s/#egg=django-wikiapp
...-e bzr+file://[email protected]#egg=version_pkg
...""" % {'repo': checkout_path})
_check_output(result.stdout, expected)
示例2: test_freeze_git_clone
def test_freeze_git_clone(script, tmpdir):
"""
Test freezing a Git clone.
"""
# Returns path to a generated package called "version_pkg"
pkg_version = _create_test_package(script)
result = script.run(
'git', 'clone', pkg_version, 'pip-test-package',
expect_stderr=True,
)
repo_dir = script.scratch_path / 'pip-test-package'
result = script.run(
'python', 'setup.py', 'develop',
cwd=repo_dir,
expect_stderr=True,
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e git+...#egg=version_pkg
...
"""
).strip()
_check_output(result.stdout, expected)
result = script.pip(
'freeze', '-f', '%s#egg=pip_test_package' % repo_dir,
expect_stderr=True,
)
expected = textwrap.dedent(
"""
-f %(repo)s#egg=pip_test_package...
-e git+...#egg=version_pkg
...
""" % {'repo': repo_dir},
).strip()
_check_output(result.stdout, expected)
# Check that slashes in branch or tag names are translated.
# See also issue #1083: https://github.com/pypa/pip/issues/1083
script.run(
'git', 'checkout', '-b', 'branch/name/with/slash',
cwd=repo_dir,
expect_stderr=True,
)
# Create a new commit to ensure that the commit has only one branch
# or tag name associated to it (to avoid the non-determinism reported
# in issue #1867).
script.run('touch', 'newfile', cwd=repo_dir)
script.run('git', 'add', 'newfile', cwd=repo_dir)
script.run('git', 'commit', '-m', '...', cwd=repo_dir)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e [email protected]#egg=version_pkg
...
"""
).strip()
_check_output(result.stdout, expected)
示例3: test_freeze_exclude_editable
def test_freeze_exclude_editable(script, tmpdir):
"""
Test excluding editable from freezing list.
"""
# Returns path to a generated package called "version_pkg"
pkg_version = _create_test_package(script)
result = script.run(
'git', 'clone', pkg_version, 'pip-test-package',
expect_stderr=True,
)
repo_dir = script.scratch_path / 'pip-test-package'
result = script.run(
'python', 'setup.py', 'develop',
cwd=repo_dir,
expect_stderr=True,
)
result = script.pip('freeze', '--exclude-editable', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e git+...#egg=version_pkg
...
"""
).strip()
_check_output(result.stdout, expected)
示例4: test_reinstalling_works_with_editible_non_master_branch
def test_reinstalling_works_with_editible_non_master_branch(script):
"""
Reinstalling an editable installation should not assume that the "master"
branch exists. See https://github.com/pypa/pip/issues/4448.
"""
version_pkg_path = _create_test_package(script)
# Switch the default branch to something other than 'master'
script.run('git', 'branch', '-m', 'foobar', cwd=version_pkg_path)
script.pip(
'install', '-e',
'%s#egg=version_pkg' %
('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
)
version = script.run('version_pkg')
assert '0.1' in version.stdout
_change_test_package_version(script, version_pkg_path)
script.pip(
'install', '-e',
'%s#egg=version_pkg' %
('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
)
version = script.run('version_pkg')
assert 'some different version' in version.stdout
示例5: _test_install_editable_from_git
def _test_install_editable_from_git(script, tmpdir, wheel):
"""Test cloning from Git."""
if wheel:
script.pip('install', 'wheel')
pkg_path = _create_test_package(script, name='testpackage', vcs='git')
args = ['install', '-e', 'git+%s#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result.assert_installed('testpackage', with_files=['.git'])
示例6: test_vcs_url_final_slash_normalization
def test_vcs_url_final_slash_normalization(script, tmpdir):
"""
Test that presence or absence of final slash in VCS URL is normalized.
"""
pkg_path = _create_test_package(script, name='testpackage', vcs='hg')
args = ['install', '-e', 'hg+%s/#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result.assert_installed('testpackage', with_files=['.hg'])
示例7: test_get_refs_should_return_branch_name_and_commit_pair
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',
cwd=version_pkg_path).stdout.strip()
git = Git()
result = git.get_refs(version_pkg_path)
assert result['master'] == commit, result
assert result['branch0.1'] == commit, result
示例8: 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
"""
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)
script.pip('install', '-e', '%[email protected]_tag#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
version = script.run('version_pkg')
assert '0.1' in version.stdout
示例9: 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
"""
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)
script.pip('install', '-e', '%[email protected]_branch#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
version = script.run('version_pkg')
assert 'some different version' in version.stdout
示例10: test_git_with_sha1_revisions
def test_git_with_sha1_revisions(script):
"""
Git backend should be able to install from SHA1 revisions
"""
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()
script.pip('install', '-e', '%[email protected]%s#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1))
version = script.run('version_pkg')
assert '0.1' in version.stdout, version.stdout
示例11: 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
version_pkg_path = _create_test_package(script)
script.pip('install', '-e', version_pkg_path.abspath)
# 'freeze'ing this should not fall over, but should result in stderr output warning
result = script.pip('freeze', expect_stderr=True)
assert "Error when trying to get requirement" in result.stderr
assert "Could not determine repository location" in result.stdout
assert "version-pkg==0.1" in result.stdout
示例12: test_get_refs_should_return_tag_name_and_commit_pair
def test_get_refs_should_return_tag_name_and_commit_pair():
env = reset_env()
version_pkg_path = _create_test_package(env)
env.run('git', 'tag', '0.1', cwd=version_pkg_path)
env.run('git', 'tag', '0.2', cwd=version_pkg_path)
commit = env.run('git', 'rev-parse', 'HEAD',
cwd=version_pkg_path).stdout.strip()
git = Git()
result = git.get_refs(version_pkg_path)
assert result['0.1'] == commit, result
assert result['0.2'] == commit, result
示例13: test_install_editable_from_svn
def test_install_editable_from_svn(script):
"""
Test checking out from svn.
"""
checkout_path = _create_test_package(script)
repo_url = _create_svn_repo(script, checkout_path)
result = script.pip(
'install',
'-e', 'svn+' + repo_url + '#egg=version-pkg'
)
result.assert_installed('version-pkg', with_files=['.svn'])
示例14: test_git_install_branch_again_after_branch_changes
def test_git_install_branch_again_after_branch_changes(script):
"""
Test installing a branch again after the branch is updated in the remote
repository.
"""
version_pkg_path = _create_test_package(script)
version = _install_version_pkg(script, version_pkg_path, rev='master')
assert version == '0.1'
_change_test_package_version(script, version_pkg_path)
version = _install_version_pkg(script, version_pkg_path, rev='master')
assert version == 'some different version'
示例15: test_get_refs_should_ignore_no_branch
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',
cwd=version_pkg_path).stdout.strip()
# current branch here is "* (nobranch)"
script.run('git', 'checkout', commit,
cwd=version_pkg_path, expect_stderr=True)
git = Git()
result = git.get_refs(version_pkg_path)
assert result['master'] == commit, result
assert result['branch0.1'] == commit, result