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

Python testing.run函数代码示例

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

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



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

示例1: it_doesnt_wheel_local_dirs

def it_doesnt_wheel_local_dirs(tmpdir):
    venv = tmpdir.join('venv')
    install_coverage(venv)

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'venv-update==' + __version__)

    run(
        venv.join('bin/pip-faster').strpath,
        'install',
        TOP.join('tests/testing/packages/dependant_package').strpath,
    )

    frozen_requirements = pip_freeze(str(venv)).split('\n')
    assert set(frozen_requirements) == {
        'coverage==ANY',
        'coverage-enable-subprocess==1.0',
        'dependant-package==1',
        'implicit-dependency==1',
        'many-versions-package==3',
        'pure-python-package==0.2.1',
        'venv-update==' + __version__,
        '',
    }

    assert {wheel.name for wheel in cached_wheels(tmpdir)} == {
        'implicit-dependency',
        'many-versions-package',
        'pure-python-package',
    }
开发者ID:Yelp,项目名称:venv-update,代码行数:30,代码来源:pip_faster.py


示例2: test_circular_dependencies

def test_circular_dependencies(tmpdir):
    """pip-faster should be able to install packages with circular
    dependencies."""
    tmpdir.chdir()
    venv = enable_coverage(tmpdir, 'venv')

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'pip-faster==' + __version__)

    out, err = run(
        venv.join('bin/pip-faster').strpath,
        'install',
        '-vv',  # show debug logging
        'circular-dep-a',
    )
    assert err == ''
    out = uncolor(out)
    assert out.endswith('''
tracing: circular-dep-a
adding sub-requirement circular-dep-b==1.0 (from circular-dep-a)
tracing: circular-dep-b==1.0 (from circular-dep-a)
adding sub-requirement circular-dep-a==1.0 (from circular-dep-b==1.0->circular-dep-a)
already analyzed: circular-dep-b==1.0 (from circular-dep-a)
tracing: circular-dep-a==1.0 (from circular-dep-b==1.0->circular-dep-a)
Circular dependency! circular-dep-a==1.0 (from circular-dep-b==1.0->circular-dep-a)
''')

    frozen_requirements = pip_freeze(str(venv)).split('\n')
    assert 'circular-dep-a==1.0' in frozen_requirements
    assert 'circular-dep-b==1.0' in frozen_requirements
开发者ID:jolynch,项目名称:pip-faster,代码行数:30,代码来源:pip_faster.py


示例3: test_multiple_issues

def test_multiple_issues(tmpdir):
    # Make it a bit worse. The output should show all three issues.
    tmpdir.chdir()
    T.requirements('flake8==2.2.5')
    T.venv_update()

    T.run('./virtualenv_run/bin/pip', 'uninstall', '--yes', 'pyflakes')
    T.requirements('''
# flake8 2.2.5 requires mccabe>=0.2.1 and pep8>=1.5.7, so this isn't satisfiable
flake8==2.2.5
mccabe==0.2
pep8==1.0
''')

    with pytest.raises(CalledProcessError) as excinfo:
        T.venv_update()
    assert excinfo.value.returncode == 1
    out, err = excinfo.value.result

    err = T.strip_coverage_warnings(err)
    assert err == ''

    out = T.uncolor(out)
    assert (
        '''
Cleaning up...
Error: version conflict: mccabe 0.2 (virtualenv_run/%s)'''
        ''' <-> mccabe>=0.2.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: version conflict: pep8 1.0 (virtualenv_run/%s) '''
        '''<-> pep8>=1.5.7 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: unmet dependency: pyflakes>=0.8.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))

Something went wrong! Sending 'virtualenv_run' back in time, so make knows it's invalid.
''' % (PYTHON_LIB, PYTHON_LIB)
    ) in out
开发者ID:ENuge,项目名称:pip-faster,代码行数:35,代码来源:conflict_test.py


示例4: it_gives_the_same_python_version_as_we_started_with

def it_gives_the_same_python_version_as_we_started_with(tmpdir):
    other_python = OtherPython()
    with tmpdir.as_cwd():
        requirements('')

        # first simulate some unrelated use of venv-update
        # this guards against statefulness in the venv-update scratch dir
        venv_update('venv=', 'unrelated_venv', 'pip-command=', 'true')

        run('virtualenv', '--python', other_python.interpreter, 'venv')
        initial_version = assert_python_version(other_python.version_prefix)

        venv_update_symlink_pwd()
        out, err = run('./venv/bin/python', 'venv_update.py')

        err = strip_pip_warnings(err)
        assert err == ''
        out = uncolor(out)
        assert out.startswith('''\
> virtualenv venv
Keeping valid virtualenv from previous run.
> rm -rf venv/local
> pip install venv-update=={}
'''.format(__version__))

        final_version = assert_python_version(other_python.version_prefix)
        assert final_version == initial_version
开发者ID:Yelp,项目名称:venv-update,代码行数:27,代码来源:validation.py


示例5: it_can_handle_a_bad_findlink

def it_can_handle_a_bad_findlink(tmpdir):
    venv = tmpdir.join('venv')
    install_coverage(venv)

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'venv-update==' + __version__)

    out, err = run(
        str(venv.join('bin/pip-faster')),
        'install', '-vvv',
        '--find-links', 'git+wat://not/a/thing',
        'pure-python-package',
    )
    out = uncolor(out)
    err = strip_pip_warnings(err)

    expected = '''\
Successfully built pure-python-package
Installing collected packages: pure-python-package
'''
    assert expected in out
    # Between this there's:
    # 'changing mode of .../venv/bin/pure-python-script to 775'
    # but that depends on umask
    _, rest = out.split(expected)
    expected2 = '''\
Successfully installed pure-python-package-0.2.1
Cleaning up...
'''
    assert expected2 in rest
    assert err == (
        "  Url 'git+wat://not/a/thing' is ignored. "
        'It is either a non-existing path or lacks a specific scheme.\n'
    )
    assert 'pure-python-package==0.2.1' in pip_freeze(str(venv)).split('\n')
开发者ID:Yelp,项目名称:venv-update,代码行数:35,代码来源:pip_faster.py


示例6: it_gives_the_same_python_version_as_we_started_with

def it_gives_the_same_python_version_as_we_started_with(tmpdir):
    other_python = OtherPython()
    with tmpdir.as_cwd():
        requirements('')

        # first simulate some unrelated use of venv-update
        # this guards against statefulness in the venv-update scratch dir
        venv_update('unrelated_venv', '--', '--version')

        run('virtualenv', '--python', other_python.interpreter, 'venv')
        initial_version = assert_python_version(other_python.version_prefix)

        venv_update_symlink_pwd()
        out, err = run('./venv/bin/python', 'venv_update.py')

        assert err == ''
        out = uncolor(out)
        assert out.startswith('''\
> virtualenv
Keeping valid virtualenv from previous run.
> venv/bin/python -m pip.__main__ install pip-faster==%s
''' % __version__)

        final_version = assert_python_version(other_python.version_prefix)
        assert final_version == initial_version
开发者ID:jolynch,项目名称:pip-faster,代码行数:25,代码来源:validation.py


示例7: it_installs_stuff_with_dash_e_without_wheeling

def it_installs_stuff_with_dash_e_without_wheeling(tmpdir):
    venv = tmpdir.join('venv')
    install_coverage(venv)

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'venv-update==' + __version__)

    # Install a package from git with no extra dependencies in editable mode.
    #
    # We need to install a package from VCS instead of the filesystem because
    # otherwise we aren't testing that editable requirements aren't wheeled
    # (and instead might just be testing that local paths aren't wheeled).
    requirements('-e git+git://github.com/Yelp/[email protected]#egg=dumb-init')  # noqa

    run(str(venv.join('bin/pip-faster')), 'install', '-r', 'requirements.txt')

    frozen_requirements = pip_freeze(str(venv)).split('\n')
    assert set(frozen_requirements) == {
        '-e git://github.com/Yelp/[email protected]#egg=dumb_init',  # noqa
        'coverage-enable-subprocess==1.0',
        'coverage==ANY',
        'venv-update==' + __version__,
        '',
    }

    # we shouldn't wheel things installed editable
    assert not tuple(cached_wheels(tmpdir))
开发者ID:Yelp,项目名称:venv-update,代码行数:27,代码来源:pip_faster.py


示例8: stage2

def stage2(executable, tmpdir):
    run(
        executable,
        venv_update.__file__,
        '--stage2',
        'myvenv',
        HOME=tmpdir.strpath,
    )
开发者ID:struys,项目名称:pip-faster,代码行数:8,代码来源:stage2_test.py


示例9: assert_c_extension_runs

def assert_c_extension_runs():
    out, err = run('venv/bin/c-extension-script')
    assert err == ''
    assert out == 'hello world\n'

    out, err = run('sh', '-c', '. venv/bin/activate && c-extension-script')
    assert err == ''
    assert out == 'hello world\n'
开发者ID:jolynch,项目名称:pip-faster,代码行数:8,代码来源:validation.py


示例10: make_venv

def make_venv():
    enable_coverage()
    venv = Path('venv')
    run('virtualenv', venv.strpath)
    install_coverage(venv.strpath)

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'venv-update==' + __version__)
    return venv
开发者ID:Yelp,项目名称:venv-update,代码行数:9,代码来源:pip_faster.py


示例11: test_is_relocatable_different_python_version

def test_is_relocatable_different_python_version(tmpdir):
    tmpdir.chdir()
    with io.open('requirements.txt', 'w') as reqs:
        reqs.write('doge==3.5.0')

    python_arg = '--python=python' + ('2.7' if not PY27 else '2.6')

    venv_update(python_arg)

    run('sh', '-c', '. virtualenv_run/bin/activate && doge --help')
开发者ID:struys,项目名称:pip-faster,代码行数:10,代码来源:relocation_test.py


示例12: test_is_relocatable

def test_is_relocatable(tmpdir):
    tmpdir.chdir()
    get_scenario('trivial')
    venv_update()

    Path('virtualenv_run').rename('relocated')

    pip = 'relocated/bin/pip'
    assert Path(pip).exists()
    run(pip, '--version')
开发者ID:struys,项目名称:pip-faster,代码行数:10,代码来源:relocation_test.py


示例13: test_relocatable

def test_relocatable(tmpdir):
    tmpdir.chdir()
    requirements('')
    venv_update()

    Path('venv').rename('relocated')

    python = 'relocated/bin/python'
    assert Path(python).exists()
    run(python, '-m', 'pip.__main__', '--version')
开发者ID:Yelp,项目名称:venv-update,代码行数:10,代码来源:relocation_test.py


示例14: enable_coverage

def enable_coverage(tmpdir):
    venv = tmpdir.join('virtualenv_run')
    if not venv.isdir():
        run('virtualenv', venv.strpath)
    run(
        venv.join('bin/python').strpath,
        '-m', 'pip.__main__',
        'install',
        '-r', TOP.join('requirements.d/coverage.txt').strpath,
    )
开发者ID:chriskuehl,项目名称:pip-faster,代码行数:10,代码来源:simple_test.py


示例15: test_relocatable

def test_relocatable(tmpdir):
    tmpdir.chdir()
    requirements('')
    venv_update('--python=python')  # this makes pypy work right. derp.

    Path('virtualenv_run').rename('relocated')

    python = 'relocated/bin/python'
    assert Path(python).exists()
    run(python, '-m', 'pip.__main__', '--version')
开发者ID:ENuge,项目名称:pip-faster,代码行数:10,代码来源:relocation_test.py


示例16: test_editable_egg_conflict

def test_editable_egg_conflict(tmpdir):
    conflicting_package = tmpdir / 'tmp/conflicting_package'
    many_versions_package_2 = tmpdir / 'tmp/many_versions_package_2'

    from shutil import copytree
    copytree(
        str(T.TOP / 'tests/testing/packages/conflicting_package'),
        str(conflicting_package),
    )

    copytree(
        str(T.TOP / 'tests/testing/packages/many_versions_package_2'),
        str(many_versions_package_2),
    )

    with many_versions_package_2.as_cwd():
        from sys import executable as python
        T.run(python, 'setup.py', 'bdist_egg', '--dist-dir', str(conflicting_package))

    with tmpdir.as_cwd():
        T.requirements('-r %s/requirements.d/coverage.txt' % T.TOP)
        T.venv_update()

        T.requirements('-e %s' % conflicting_package)
        with pytest.raises(CalledProcessError) as excinfo:
            T.venv_update()
        assert excinfo.value.returncode == 1
        out, err = excinfo.value.result

        err = T.strip_coverage_warnings(err)
        assert err == ''

        out = T.uncolor(out)
        expected = '\nSuccessfully installed many-versions-package conflicting-package\n'
        assert expected in out
        rest = out.rsplit(expected, 1)[-1]

        if True:  # :pragma:nocover:pylint:disable=using-constant-test
            # Debian de-vendorizes the version of pip it ships
            try:
                from sysconfig import get_python_version
            except ImportError:  # <= python2.6
                from distutils.sysconfig import get_python_version
        assert (
            '''\
Cleaning up...
Error: version conflict: many-versions-package 2 (tmp/conflicting_package/many_versions_package-2-py{0}.egg)'''
            ''' <-> many-versions-package<2 (from conflicting-package==1->-r requirements.txt (line 1))
Storing debug log for failure in {1}/home/.pip/pip.log

Something went wrong! Sending 'venv' back in time, so make knows it's invalid.
'''.format(get_python_version(), tmpdir)
        ) == rest

        assert_venv_marked_invalid(tmpdir.join('venv'))
开发者ID:jolynch,项目名称:pip-faster,代码行数:55,代码来源:conflict_test.py


示例17: it_gives_proper_error_without_requirements

def it_gives_proper_error_without_requirements(tmpdir):
    venv = tmpdir.join('venv')
    install_coverage(venv)

    pip = venv.join('bin/pip').strpath
    run(pip, 'install', 'venv-update==' + __version__)

    with pytest.raises(CalledProcessError) as exc_info:
        run(str(venv.join('bin/pip-faster')), 'install')
    _, err = exc_info.value.result
    assert err.startswith('ERROR: You must give at least one requirement to install')
开发者ID:Yelp,项目名称:venv-update,代码行数:11,代码来源:pip_faster.py


示例18: pypi_packages

def pypi_packages(tmpdir_factory):
    package_temp = tmpdir_factory.ensuretemp("venv-update-packages")
    with TOP.as_cwd():
        run(
            sys.executable,
            "tests/testing/make_sdists.py",
            "tests/testing/packages",
            ".",  # we need pip-faster to be installable too
            str(package_temp),
        )

    yield package_temp
开发者ID:jolynch,项目名称:pip-faster,代码行数:12,代码来源:conftest.py


示例19: pypi_packages

def pypi_packages():
    package_temp = TOP.join('build/test-packages')
    with TOP.as_cwd():
        run(
            sys.executable,
            'tests/testing/make_sdists.py',
            'tests/testing/packages',
            '.',  # we need venv-update to be installable too
            str(package_temp),
        )

    yield package_temp
开发者ID:Yelp,项目名称:venv-update,代码行数:12,代码来源:conftest.py


示例20: test_update_while_active

def test_update_while_active(tmpdir, capfd):
    tmpdir.chdir()
    get_scenario('trivial')

    venv_update()
    assert 'mccabe' not in pip_freeze(capfd)

    with open('requirements.txt', 'w') as requirements:
        # An arbitrary small package: mccabe
        requirements.write('mccabe')

    venv_update_symlink_pwd()
    run('sh', '-c', '. virtualenv_run/bin/activate && python venv_update.py')
    assert 'mccabe' in pip_freeze(capfd)
开发者ID:struys,项目名称:pip-faster,代码行数:14,代码来源:simple_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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