• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python lib.path_to_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.lib.path_to_url函数的典型用法代码示例。如果您正苦于以下问题:Python path_to_url函数的具体用法?Python path_to_url怎么用?Python path_to_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了path_to_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_pip_wheel_ignore_wheels_editables

def test_pip_wheel_ignore_wheels_editables(script, data):
    """
    Test 'pip wheel' ignores editables and *.whl files in requirements
    """
    script.pip('install', 'wheel')

    local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % data.find_links
    local_editable = data.packages.join("FSPkg")
    script.scratch_path.join("reqs.txt").write(textwrap.dedent("""\
        %s
        -e %s
        simple
        """ % (local_wheel, local_editable)))
    result = script.pip('wheel', '--no-index', '-f', data.find_links, '-r', script.scratch_path / 'reqs.txt')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = script.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path in result.files_created, (wheel_file_path, result.files_created)
    assert "Successfully built simple" in result.stdout, result.stdout
    assert "Failed to build" not in result.stdout, result.stdout
    assert "ignoring %s" % local_wheel in result.stdout
    ignore_editable = "ignoring %s" % path_to_url(local_editable)
    #TODO: understand this divergence
    if sys.platform == 'win32':
        ignore_editable = "ignoring %s" % path_to_url_d(local_editable)
    assert ignore_editable in result.stdout, result.stdout
开发者ID:Aneudylab,项目名称:pip,代码行数:25,代码来源:test_wheel.py


示例2: _get_vcs_and_checkout_url

def _get_vcs_and_checkout_url(remote_repository, directory):
    vcs_classes = {'svn': subversion.Subversion,
                   'git': git.Git,
                   'bzr': bazaar.Bazaar,
                   'hg': mercurial.Mercurial}
    default_vcs = 'svn'
    if '+' not in remote_repository:
        remote_repository = '%s+%s' % (default_vcs, remote_repository)
    vcs, repository_path = remote_repository.split('+', 1)
    vcs_class = vcs_classes[vcs]
    branch = ''
    if vcs == 'svn':
        branch = os.path.basename(remote_repository)
        # remove the slash
        repository_name = os.path.basename(
            remote_repository[:-len(branch) - 1]
        )
    else:
        repository_name = os.path.basename(remote_repository)

    destination_path = os.path.join(directory, repository_name)
    if not os.path.exists(destination_path):
        vcs_class(remote_repository).obtain(destination_path)
    return '%s+%s' % (
        vcs,
        path_to_url('/'.join([directory, repository_name, branch])),
    )
开发者ID:alquerci,项目名称:pip,代码行数:27,代码来源:local_repos.py


示例3: test_pip_wheel_ignore_wheels_editables

def test_pip_wheel_ignore_wheels_editables():
    """
    Test 'pip wheel' ignores editables and *.whl files in requirements
    """
    env = reset_env()
    pip_install_local('wheel')

    local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links
    local_editable = os.path.abspath(os.path.join(tests_data, 'packages', 'FSPkg'))
    write_file('reqs.txt', textwrap.dedent("""\
        %s
        -e %s
        simple
        """ % (local_wheel, local_editable)))
    result = run_pip('wheel', '--no-index', '-f', find_links, '-r', env.scratch_path / 'reqs.txt')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path in result.files_created, (wheel_file_path, result.files_created)
    assert "Successfully built simple" in result.stdout, result.stdout
    assert "Failed to build" not in result.stdout, result.stdout
    assert "ignoring %s" % local_wheel in result.stdout
    ignore_editable = "ignoring %s" % path_to_url(local_editable)
    #TODO: understand this divergence
    if sys.platform == 'win32':
        ignore_editable = "ignoring %s" % path_to_url_d(local_editable)
    assert ignore_editable in result.stdout, result.stdout
开发者ID:Basis,项目名称:pip,代码行数:26,代码来源:test_wheel.py


示例4: 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'])
开发者ID:alquerci,项目名称:pip,代码行数:8,代码来源:test_install.py


示例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'])
开发者ID:nvdv,项目名称:pip,代码行数:8,代码来源:test_install.py


示例6: test_install_with_extras_from_install

def test_install_with_extras_from_install(script, data):
    to_install = data.packages.join("LocalExtras")
    script.scratch_path.join("constraints.txt").write(
        "%s#egg=LocalExtras" % path_to_url(to_install)
    )
    result = script.pip_install_local(
        '-c', script.scratch_path / 'constraints.txt', 'LocalExtras[baz]')
    assert script.site_packages / 'singlemodule.py'in result.files_created
开发者ID:jonparrott,项目名称:pip,代码行数:8,代码来源:test_install_reqs.py


示例7: test_sort_locations_file_not_find_link

def test_sort_locations_file_not_find_link():
    """
    Test that a file:// url dir that's not a find-link, doesn't get a listdir run
    """
    index_url = path_to_url(os.path.join(tests_data, 'indexes', 'empty_with_pkg'))
    finder = PackageFinder([], [])
    files, urls = finder._sort_locations([index_url])
    assert urls and not files, "urls, but not files should have been found"
开发者ID:Basis,项目名称:pip,代码行数:8,代码来源:test_index.py


示例8: test_constraints_constrain_to_local

def test_constraints_constrain_to_local(script, data):
    to_install = data.src.join("singlemodule")
    script.scratch_path.join("constraints.txt").write(
        "%s#egg=singlemodule" % path_to_url(to_install)
    )
    result = script.pip(
        'install', '--no-index', '-f', data.find_links, '-c',
        script.scratch_path / 'constraints.txt', 'singlemodule')
    assert 'Running setup.py install for singlemodule' in result.stdout
开发者ID:jonparrott,项目名称:pip,代码行数:9,代码来源:test_install_reqs.py


示例9: test_constrained_to_url_install_same_url

def test_constrained_to_url_install_same_url(script, data):
    to_install = data.src.join("singlemodule")
    constraints = path_to_url(to_install) + "#egg=singlemodule"
    script.scratch_path.join("constraints.txt").write(constraints)
    result = script.pip(
        'install', '--no-index', '-f', data.find_links, '-c',
        script.scratch_path / 'constraints.txt', to_install)
    assert ('Running setup.py install for singlemodule'
            in result.stdout), str(result)
开发者ID:jonparrott,项目名称:pip,代码行数:9,代码来源:test_install_reqs.py


示例10: test_install_from_file_index_hash_link

def test_install_from_file_index_hash_link():
    """
    Test that a pkg can be installed from a file:// index using a link with a hash
    """
    env = reset_env()
    index_url = path_to_url(os.path.join(tests_data, 'indexes', 'simple'))
    result = run_pip('install', '-i', index_url, 'simple==1.0')
    egg_info_folder = env.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
    assert egg_info_folder in result.files_created, str(result)
开发者ID:CLOKER,项目名称:pip,代码行数:9,代码来源:test_install_index.py


示例11: test_file_index_url_quoting

def test_file_index_url_quoting():
    """
    Test url quoting of file index url with a space
    """
    index_url = path_to_url(os.path.join(tests_data, 'indexes', urllib.quote('in dex')))
    env = reset_env()
    result = run_pip('install', '-vvv', '--index-url', index_url, 'simple', expect_error=False)
    assert (env.site_packages/'simple') in result.files_created, str(result.stdout)
    assert (env.site_packages/'simple-1.0-py%s.egg-info' % pyversion) in result.files_created, str(result)
开发者ID:CLOKER,项目名称:pip,代码行数:9,代码来源:test_install_index.py


示例12: test_install_local_with_subdirectory

def test_install_local_with_subdirectory(script):
    version_pkg_path = _create_test_package_with_subdirectory(script,
                                                              'version_subdir')
    result = script.pip(
        'install',
        '%s#egg=version_subpkg&subdirectory=version_subdir' %
        ('git+' + path_to_url(version_pkg_path),)
    )

    result.assert_installed('version_subpkg.py', editable=False)
开发者ID:jonparrott,项目名称:pip,代码行数:10,代码来源:test_install_reqs.py


示例13: test_install_local_editable_with_subdirectory

def test_install_local_editable_with_subdirectory(script):
    version_pkg_path = _create_test_package_with_subdirectory(script,
                                                              'version_subdir')
    result = script.pip(
        'install', '-e',
        '%s#egg=version_subpkg&subdirectory=version_subdir' %
        ('git+%s' % path_to_url(version_pkg_path),)
    )

    result.assert_installed('version-subpkg', sub_dir='version_subdir')
开发者ID:jonparrott,项目名称:pip,代码行数:10,代码来源:test_install_reqs.py


示例14: test_finder_ignores_external_links

def test_finder_ignores_external_links():
    """
    Tests that PackageFinder ignores external links, with or without hashes.
    """
    req = InstallRequirement.from_line("bar", None)

    # using a local index
    index_url = path_to_url(os.path.join(tests_data, "indexes", "externals"))
    finder = PackageFinder([], [index_url])
    link = finder.find_requirement(req, False)
    assert link.filename == "bar-1.0.tar.gz"
开发者ID:Basis,项目名称:pip,代码行数:11,代码来源:test_finder.py


示例15: test_finder_finds_external_links_with_hashes_all

def test_finder_finds_external_links_with_hashes_all():
    """
    Tests that PackageFinder finds external links but only if they have a hash
    using the all externals flag.
    """
    req = InstallRequirement.from_line("bar", None)

    # using a local index
    index_url = path_to_url(os.path.join(tests_data, "indexes", "externals"))
    finder = PackageFinder([], [index_url], allow_all_external=True)
    link = finder.find_requirement(req, False)
    assert link.filename == "bar-2.0.tar.gz"
开发者ID:Basis,项目名称:pip,代码行数:12,代码来源:test_finder.py


示例16: test_finder_installs_dev_releases

def test_finder_installs_dev_releases():
    """
    Test PackageFinder finds dev releases if asked to.
    """

    req = InstallRequirement.from_line("bar", None, prereleases=True)

    # using a local index (that has dev releases)
    index_url = path_to_url(os.path.join(tests_data, 'indexes', 'dev'))
    finder = PackageFinder([], [index_url])
    link = finder.find_requirement(req, False)
    assert link.url.endswith("bar-2.0.dev1.tar.gz"), link.url
开发者ID:Basis,项目名称:pip,代码行数:12,代码来源:test_finder.py


示例17: 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(tests_data, '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:Basis,项目名称:pip,代码行数:13,代码来源:test_install_reqs.py


示例18: test_finder_finds_external_links_without_hashes_per_project

def test_finder_finds_external_links_without_hashes_per_project():
    """
    Tests that PackageFinder finds external links if they do not have a hash
    """
    req = InstallRequirement.from_line("bar==3.0", None)

    # using a local index
    index_url = path_to_url(os.path.join(tests_data, "indexes", "externals"))
    finder = PackageFinder([], [index_url],
                allow_external=["bar"],
                allow_insecure=["bar"],
            )
    link = finder.find_requirement(req, False)
    assert link.filename == "bar-3.0.tar.gz"
开发者ID:Basis,项目名称:pip,代码行数:14,代码来源:test_finder.py


示例19: test_finder_finds_external_links_without_hashes_scraped_per_project_all_insecure

def test_finder_finds_external_links_without_hashes_scraped_per_project_all_insecure():
    """
    Tests that PackageFinder finds externally scraped links
    """
    req = InstallRequirement.from_line("bar", None)

    # using a local index
    index_url = path_to_url(os.path.join(tests_data, "indexes", "externals"))
    finder = PackageFinder([], [index_url],
                allow_external=["bar"],
                allow_all_insecure=True,
            )
    link = finder.find_requirement(req, False)
    assert link.filename == "bar-4.0.tar.gz"
开发者ID:Basis,项目名称:pip,代码行数:14,代码来源:test_finder.py


示例20: handle_install_request

def handle_install_request(script, requirement):
    assert isinstance(requirement, str), (
        "Need install requirement to be a string only"
    )
    result = script.pip(
        "install",
        "--no-index", "--find-links", path_to_url(script.scratch_path),
        requirement
    )

    retval = {}
    if result.returncode == 0:
        # Check which packages got installed
        retval["install"] = []

        for path in result.files_created:
            if path.endswith(".dist-info"):
                name, version = (
                    os.path.basename(path)[:-len(".dist-info")]
                ).rsplit("-", 1)

                # TODO: information about extras.

                retval["install"].append(" ".join((name, version)))

        retval["install"].sort()

        # TODO: Support checking uninstallations
        # retval["uninstall"] = []

    elif "conflicting" in result.stderr.lower():
        retval["conflicting"] = []

        message = result.stderr.rsplit("\n", 1)[-1]

        # XXX: There might be a better way than parsing the message
        for match in re.finditer(message, _conflict_finder_re):
            di = match.groupdict()
            retval["conflicting"].append(
                {
                    "required_by": "{} {}".format(di["name"], di["version"]),
                    "selector": di["selector"]
                }
            )

    return retval
开发者ID:akaihola,项目名称:pip,代码行数:46,代码来源:test_yaml.py



注:本文中的tests.lib.path_to_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lib.replace_attr函数代码示例发布时间:2022-05-27
下一篇:
Python lib.assert_all_changes函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap