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

Python lib.run_pip函数代码示例

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

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



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

示例1: test_upgrade_vcs_req_with_no_dists_found

def test_upgrade_vcs_req_with_no_dists_found():
    """It can upgrade a VCS requirement that has no distributions otherwise."""
    reset_env()
    req = "%s#egg=pip-test-package" % local_checkout("git+http://github.com/pypa/pip-test-package.git")
    run_pip("install", req)
    result = run_pip("install", "-U", req)
    assert not result.returncode
开发者ID:Basis,项目名称:pip,代码行数:7,代码来源:test_install_upgrade.py


示例2: 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:Basis,项目名称:pip,代码行数:25,代码来源:test_uninstall.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:CLOKER,项目名称:pip,代码行数:27,代码来源:test_install_download.py


示例4: test_uninstall_overlapping_package

def test_uninstall_overlapping_package():
    """
    Uninstalling a distribution that adds modules to a pre-existing package
    should only remove those added modules, not the rest of the existing
    package.

    See: GitHub issue #355 (pip uninstall removes things it didn't install)
    """
    parent_pkg = abspath(join(tests_data, 'packages', 'parent-0.1.tar.gz'))
    child_pkg = abspath(join(tests_data, 'packages', 'child-0.1.tar.gz'))
    env = reset_env()
    result1 = run_pip('install', parent_pkg, expect_error=False)
    assert join(env.site_packages, 'parent') in result1.files_created, sorted(result1.files_created.keys())
    result2 = run_pip('install', child_pkg, expect_error=False)
    assert join(env.site_packages, 'child') in result2.files_created, sorted(result2.files_created.keys())
    assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result2.files_created, sorted(result2.files_created.keys())
    #the import forces the generation of __pycache__ if the version of python supports it
    env.run('python', '-c', "import parent.plugins.child_plugin, child")
    result3 = run_pip('uninstall', '-y', 'child', expect_error=False)
    assert join(env.site_packages, 'child') in result3.files_deleted, sorted(result3.files_created.keys())
    assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result3.files_deleted, sorted(result3.files_deleted.keys())
    assert join(env.site_packages, 'parent') not in result3.files_deleted, sorted(result3.files_deleted.keys())
    # Additional check: uninstalling 'child' should return things to the
    # previous state, without unintended side effects.
    assert_all_changes(result2, result3, [])
开发者ID:Basis,项目名称:pip,代码行数:25,代码来源:test_uninstall.py


示例5: 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:Basis,项目名称:pip,代码行数:30,代码来源:test_install_upgrade.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 = pip_install_local('simple')
    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:Basis,项目名称:pip,代码行数:34,代码来源:test_freeze.py


示例7: test_freeze_git_clone

def test_freeze_git_clone():
    """
    Test freezing a Git clone.

    """
    env = reset_env()
    result = env.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git'), 'pip-test-package')
    result = env.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
            cwd=env.scratch_path / 'pip-test-package', expect_stderr=True)
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path / 'pip-test-package')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        ...-e %[email protected]#egg=pip_test_package-...
        ...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze -f %(repo)s#egg=pip_test_package
        -- stdout: --------------------
        -f %(repo)s#egg=pip_test_package...
        -e %(repo)[email protected]#egg=pip_test_package-0.1.1
        ...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git')})
    _check_output(result, expected)
开发者ID:Basis,项目名称:pip,代码行数:29,代码来源:test_freeze.py


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


示例9: 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)
开发者ID:Basis,项目名称:pip,代码行数:29,代码来源:test_freeze.py


示例10: 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', 'c9963c111e7c',
                     local_repo('hg+http://bitbucket.org/pypa/pip-test-package'),
                     'pip-test-package')
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path/'pip-test-package', expect_stderr=True)
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        ...-e %[email protected]#egg=pip_test_package-...
        ...""" % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s#egg=pip_test_package' % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze -f %(repo)s#egg=pip_test_package
        -- stdout: --------------------
        -f %(repo)s#egg=pip_test_package
        ...-e %(repo)[email protected]#egg=pip_test_package-dev
        ...""" % {'repo': local_checkout('hg+http://bitbucket.org/pypa/pip-test-package')})
    _check_output(result, expected)
开发者ID:Basis,项目名称:pip,代码行数:31,代码来源:test_freeze.py


示例11: 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(tests_data, '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
    env.assert_no_temp()

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
开发者ID:Basis,项目名称:pip,代码行数:33,代码来源:test_bundle.py


示例12: test_install_user_conflict_in_globalsite

    def test_install_user_conflict_in_globalsite(self):
        """
        Test user install with conflict in global site ignores site and installs to usersite
        """

        # the test framework only supports testing using virtualenvs
        # the sys.path ordering for virtualenvs with --system-site-packages is this: virtualenv-site, user-site, global-site
        # this test will use 2 modifications to simulate the user-site/global-site relationship
        # 1) a monkey patch which will make it appear INITools==0.2 is not in in the virtualenv site
        #    if we don't patch this, pip will return an installation error:  "Will not install to the usersite because it will lack sys.path precedence..."
        # 2) adding usersite to PYTHONPATH, so usersite as sys.path precedence over the virtualenv site

        env = reset_env(system_site_packages=True, sitecustomize=patch_dist_in_site_packages)
        env.environ["PYTHONPATH"] = env.root_path / env.user_site

        result1 = run_pip('install', 'INITools==0.2')
        result2 = run_pip('install', '--user', 'INITools==0.1')

        #usersite has 0.1
        egg_info_folder = env.user_site / 'INITools-0.1-py%s.egg-info' % pyversion
        initools_folder = env.user_site / 'initools'
        assert egg_info_folder in result2.files_created, str(result2)
        assert initools_folder in result2.files_created, str(result2)

        #site still has 0.2 (can't look in result1; have to check)
        egg_info_folder = env.root_path / env.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
        initools_folder = env.root_path / env.site_packages / 'initools'
        assert isdir(egg_info_folder)
        assert isdir(initools_folder)
开发者ID:Basis,项目名称:pip,代码行数:29,代码来源:test_install_user.py


示例13: _test_uninstall_editable_with_source_outside_venv

def _test_uninstall_editable_with_source_outside_venv(tmpdir):
    env = reset_env()
    result = env.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv'), tmpdir)
    result2 = run_pip('install', '-e', tmpdir)
    assert (join(env.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys())
    result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
    assert_all_changes(result, result3, [env.venv/'build'])
开发者ID:Basis,项目名称:pip,代码行数:7,代码来源:test_uninstall.py


示例14: 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(tests_data, 'packages'))
    run_pip('install', 'paxpkg.tar.bz2', cwd=run_from)
开发者ID:Basis,项目名称:pip,代码行数:7,代码来源:test_install.py


示例15: test_uninstall_from_usersite

 def test_uninstall_from_usersite(self):
     """
     Test uninstall from usersite
     """
     env = reset_env(system_site_packages=True)
     result1 = run_pip('install', '--user', 'INITools==0.3')
     result2 = run_pip('uninstall', '-y', 'INITools')
     assert_all_changes(result1, result2, [env.venv/'build', 'cache'])
开发者ID:Basis,项目名称:pip,代码行数:8,代码来源:test_install_user.py


示例16: 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]"
    run_pip("install", req)
    result = run_pip("install", "-U", req)
    assert not "pypi.python.org" in result.stdout, result.stdout
开发者ID:CLOKER,项目名称:pip,代码行数:8,代码来源:test_install_upgrade.py


示例17: test_show_with_all_files

def test_show_with_all_files():
    """
    Test listing all files in the show command.

    """
    reset_env()
    result = run_pip('install', 'initools==0.2')
    result = run_pip('show', '--files', 'initools')
    assert re.search(r"Files:\n(  .+\n)+", result.stdout)
开发者ID:Basis,项目名称:pip,代码行数:9,代码来源:test_show.py


示例18: test_setup_py_with_dos_line_endings

def test_setup_py_with_dos_line_endings():
    """
    It doesn't choke on a setup.py file that uses DOS line endings (\\r\\n).

    Refs https://github.com/pypa/pip/issues/237
    """
    reset_env()
    to_install = os.path.abspath(os.path.join(tests_data, 'packages', 'LineEndings'))
    run_pip('install', to_install, expect_error=False)
开发者ID:Basis,项目名称:pip,代码行数:9,代码来源:test_install_compat.py


示例19: test_local_flag

def test_local_flag():
    """
    Test the behavior of --local flag in the list command

    """
    reset_env()
    run_pip('install', '-f', find_links, '--no-index', 'simple==1.0')
    result = run_pip('list', '--local')
    assert 'simple (1.0)' in result.stdout
开发者ID:Basis,项目名称:pip,代码行数:9,代码来源:test_list.py


示例20: test_no_upgrade_unless_requested

def test_no_upgrade_unless_requested():
    """
    No upgrade if not specifically requested.

    """
    reset_env()
    run_pip('install', 'INITools==0.1', expect_error=True)
    result = run_pip('install', 'INITools', expect_error=True)
    assert not result.files_created, 'pip install INITools upgraded when it should not have'
开发者ID:CLOKER,项目名称:pip,代码行数:9,代码来源:test_install_upgrade.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python config_mock.get_powerline函数代码示例发布时间:2022-05-27
下一篇:
Python lib.reset_env函数代码示例发布时间: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