本文整理汇总了Python中testing.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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',
}
示例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
示例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
示例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
示例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')
示例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
示例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))
示例8: stage2
def stage2(executable, tmpdir):
run(
executable,
venv_update.__file__,
'--stage2',
'myvenv',
HOME=tmpdir.strpath,
)
示例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'
示例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
示例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')
示例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')
示例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')
示例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,
)
示例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')