本文整理汇总了Python中tests.helpers.run_in函数的典型用法代码示例。如果您正苦于以下问题:Python run_in函数的具体用法?Python run_in怎么用?Python run_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_in函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_activate_help
def test_activate_help():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
{activate} {envs}/test1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "Usage: source activate ENV" in stderr
commands = (command_setup + """
source {activate} --help
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "Usage: source activate ENV" in stderr
commands = (command_setup + """
{deactivate}
""").format(envs=envs, deactivate=deactivate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "Usage: source deactivate" in stderr
commands = (command_setup + """
source {deactivate} --help
""").format(envs=envs, deactivate=deactivate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "Usage: source deactivate" in stderr
开发者ID:amfarrell,项目名称:conda,代码行数:35,代码来源:test_activate.py
示例2: test_wrong_args
def test_wrong_args():
for shell in shells:
with TemporaryDirectory(prefix="envs", dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (
command_setup
+ """
source {activate}
printf $PATH
"""
).format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == "Error: no environment provided.\n"
commands = (
command_setup
+ """
source {activate} two args
printf $PATH
"""
).format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == "Error: did not expect more than one argument.\n"
commands = (
command_setup
+ """
source {deactivate} test
printf $PATH
"""
).format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == "Error: too many arguments.\n"
commands = (
command_setup
+ """
source {deactivate} {envs}/test
printf $PATH
"""
).format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == "Error: too many arguments.\n"
开发者ID:ARF1,项目名称:conda,代码行数:51,代码来源:test_activate.py
示例3: test_activate_test1
def test_activate_test1():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {activate} {envs}/test1
printf $PATH
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == envs + "/test1/bin:" + PATH
assert stderr == 'discarding {syspath} from PATH\nprepending {envs}/test1/bin to PATH\n'.format(envs=envs, syspath=syspath)
开发者ID:Trentonoliphant,项目名称:conda,代码行数:12,代码来源:test_activate.py
示例4: test_deactivate
def test_deactivate():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {deactivate}
printf $PATH
""").format(envs=envs, deactivate=deactivate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == 'Error: No environment to deactivate\n'
开发者ID:Trentonoliphant,项目名称:conda,代码行数:12,代码来源:test_activate.py
示例5: test_activate_test3
def test_activate_test3():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {activate} {envs}/test3
printf $PATH
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == 'Error: no such directory: {envs}/test3/bin\n'.format(envs=envs)
开发者ID:Trentonoliphant,项目名称:conda,代码行数:12,代码来源:test_activate.py
示例6: test_activate_test1_deactivate
def test_activate_test1_deactivate():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {activate} {envs}/test1 2> /dev/null
source {deactivate}
printf $PATH
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ROOTPATH
assert stderr == 'discarding {envs}/test1/bin from PATH\n'.format(envs=envs)
开发者ID:Trentonoliphant,项目名称:conda,代码行数:13,代码来源:test_activate.py
示例7: test_CONDA_DEFAULT_ENV
def test_CONDA_DEFAULT_ENV():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {activate} {envs}/test1
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '{envs}/test1'.format(envs=envs)
assert stderr == 'discarding {syspath} from PATH\nprepending {envs}/test1/bin to PATH\n'.format(envs=envs, syspath=syspath)
commands = (command_setup + """
source {activate} {envs}/test1 2> /dev/null
source {activate} {envs}/test2
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '{envs}/test2'.format(envs=envs)
assert stderr == 'discarding {envs}/test1/bin from PATH\nprepending {envs}/test2/bin to PATH\n'.format(envs=envs)
commands = (command_setup + """
source {activate} {envs}/test3
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: no such directory: {envs}/test3/bin\n'.format(envs=envs)
commands = (command_setup + """
source {activate} {envs}/test1 2> /dev/null
source {activate} {envs}/test3
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '{envs}/test1'.format(envs=envs)
assert stderr == 'Error: no such directory: {envs}/test3/bin\n'.format(envs=envs)
commands = (command_setup + """
source {deactivate}
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: No environment to deactivate\n'
commands = (command_setup + """
source {activate} {envs}/test1 2> /dev/null
source {deactivate}
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'discarding {envs}/test1/bin from PATH\n'.format(envs=envs)
commands = (command_setup + """
source {activate}
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: no environment provided.\n'
commands = (command_setup + """
source {activate} two args
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: did not expect more than one argument.\n'
commands = (command_setup + """
source {deactivate} test
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: too many arguments.\n'
commands = (command_setup + """
source {deactivate} {envs}/test
printf "$CONDA_DEFAULT_ENV"
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert stderr == 'Error: too many arguments.\n'
开发者ID:Trentonoliphant,项目名称:conda,代码行数:96,代码来源:test_activate.py
示例8: test_PS1_no_changeps1
def test_PS1_no_changeps1():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
with open(join(envs, '.condarc'), 'w') as f:
f.write("""\
changeps1: no
""")
condarc = """
CONDARC="{envs}/.condarc"
"""
commands = (command_setup + condarc + """
source {activate} {envs}/test1
printf $PS1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'discarding {syspath} from PATH\nprepending {envs}/test1/bin to PATH\n'.format(envs=envs, syspath=syspath)
commands = (command_setup + condarc + """
source {activate} {envs}/test1 2> /dev/null
source {activate} {envs}/test2
printf $PS1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'discarding {envs}/test1/bin from PATH\nprepending {envs}/test2/bin to PATH\n'.format(envs=envs)
commands = (command_setup + condarc + """
source {activate} {envs}/test3
printf $PS1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: no such directory: {envs}/test3/bin\n'.format(envs=envs)
commands = (command_setup + condarc + """
source {activate} {envs}/test1 2> /dev/null
source {activate} {envs}/test3
printf $PS1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: no such directory: {envs}/test3/bin\n'.format(envs=envs)
commands = (command_setup + condarc + """
source {deactivate}
printf $PS1
""").format(envs=envs, deactivate=deactivate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: No environment to deactivate\n'
commands = (command_setup + condarc + """
source {activate} {envs}/test1 2> /dev/null
source {deactivate}
printf $PS1
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'discarding {envs}/test1/bin from PATH\n'.format(envs=envs)
commands = (command_setup + condarc + """
source {activate}
printf $PS1
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: no environment provided.\n'
commands = (command_setup + condarc + """
source {activate} two args
printf $PS1
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: did not expect more than one argument.\n'
commands = (command_setup + condarc + """
source {deactivate} test
printf $PS1
""").format(envs=envs, deactivate=deactivate, activate=activate)
stdout, stderr = run_in(commands, shell)
assert stdout == '$'
assert stderr == 'Error: too many arguments.\n'
commands = (command_setup + condarc + """
source {deactivate} {envs}/test
printf $PS1
""").format(envs=envs, deactivate=deactivate, activate=activate)
#.........这里部分代码省略.........
开发者ID:Trentonoliphant,项目名称:conda,代码行数:101,代码来源:test_activate.py
示例9: test_activate_symlinking
def test_activate_symlinking():
for shell in shells:
with TemporaryDirectory(prefix='envs', dir=dirname(__file__)) as envs:
activate, deactivate, conda = _write_entry_points(envs)
commands = (command_setup + """
source {activate} {envs}/test1
""").format(envs=envs, activate=activate)
stdout, stderr = run_in(commands, shell)
assert not stdout
assert stderr == 'discarding {syspath} from PATH\nprepending {envs}/test1/bin to PATH\n'.format(envs=envs, syspath=syspath)
for f in ['conda', 'activate', 'deactivate']:
assert os.path.lexists('{envs}/test1/bin/{f}'.format(envs=envs, f=f))
assert os.path.exists('{envs}/test1/bin/{f}'.format(envs=envs, f=f))
s = os.lstat('{envs}/test1/bin/{f}'.format(envs=envs, f=f))
assert stat.S_ISLNK(s.st_mode)
assert os.readlink('{envs}/test1/bin/{f}'.format(envs=envs,
f=f)) == '{syspath}/{f}'.format(syspath=syspath, f=f)
try:
# Test activate when there are no write permissions in the
# env. There are two cases:
# - conda/deactivate/activate are already symlinked
commands = (command_setup + """
mkdir -p {envs}/test3/bin
ln -s {activate} {envs}/test3/bin/activate
ln -s {deactivate} {envs}/test3/bin/deactivate
ln -s {conda} {envs}/test3/bin/conda
chmod 555 {envs}/test3/bin
source {activate} {envs}/test3
""").format(envs=envs, activate=activate, deactivate=deactivate, conda=conda)
stdout, stderr = run_in(commands, shell)
assert not stdout
assert stderr == 'discarding {syspath} from PATH\nprepending {envs}/test3/bin to PATH\n'.format(envs=envs, syspath=syspath)
# Make sure it stays the same
for f in ['conda', 'activate', 'deactivate']:
assert os.path.lexists('{envs}/test3/bin/{f}'.format(envs=envs, f=f))
assert os.path.exists('{envs}/test3/bin/{f}'.format(envs=envs, f=f))
s = os.lstat('{envs}/test3/bin/{f}'.format(envs=envs, f=f))
assert stat.S_ISLNK(s.st_mode)
assert os.readlink('{envs}/test3/bin/{f}'.format(envs=envs,
f=f)) == '{f}'.format(f=locals()[f])
# - conda/deactivate/activate are not symlinked. In this case,
# activate should fail
commands = (command_setup + """
mkdir -p {envs}/test4/bin
chmod 555 {envs}/test4/bin
source {activate} {envs}/test4
echo $PATH
echo $CONDA_DEFAULT_ENV
""").format(envs=envs, activate=activate, deactivate=deactivate, conda=conda)
stdout, stderr = run_in(commands, shell)
assert stdout == (
'{ROOTPATH}\n' # PATH
'\n' # CONDA_DEFAULT_ENV
).format(ROOTPATH=ROOTPATH)
assert stderr == ('Cannot activate environment {envs}/test4, '
'do not have write access to write conda symlink\n').format(envs=envs)
finally:
# Change the permissions back so that we can delete the directory
run_in('chmod 777 {envs}/test3/bin'.format(envs=envs), shell)
run_in('chmod 777 {envs}/test4/bin'.format(envs=envs), shell)
开发者ID:Trentonoliphant,项目名称:conda,代码行数:66,代码来源:test_activate.py
示例10: run_in
import os
from os.path import dirname, join
import shutil
import stat
import subprocess
from conda.compat import TemporaryDirectory
from conda.config import root_dir, platform
from tests.helpers import run_in
# Only run these tests for commands that are installed.
shells = []
for shell in ['bash', 'zsh']:
try:
stdout, stderr = run_in('echo', shell)
except OSError:
pass
else:
if not stderr:
shells.append(shell)
# activate and deactivate are no longer part conda, so we can't copy them
# from the source tree. They should normally be installed, so this pulls
# them from the path.
process = subprocess.Popen(['which', 'activate'], stdout=subprocess.PIPE)
output = process.communicate()[0]
activate_path = output.strip().decode('utf-8')
deactivate_path = join(dirname(activate_path), 'deactivate')
开发者ID:Trentonoliphant,项目名称:conda,代码行数:29,代码来源:test_activate.py
示例11: run_in
from conda.compat import TemporaryDirectory
from conda.config import root_dir, platform
from tests.helpers import run_in
# Only run these tests for commands that are installed.
if platform == "win":
skip_tests = True
shells = []
else:
shells = []
for shell in ["bash", "zsh"]:
try:
stdout, stderr = run_in("echo", shell)
except OSError:
pass
else:
if not stderr:
shells.append(shell)
# activate and deactivate are no longer part conda, so we can't copy them
# from the source tree. They should normally be installed, so this pulls
# them from the path.
process = subprocess.Popen(["which", "activate"], stdout=subprocess.PIPE)
output = process.communicate()[0]
activate_path = output.strip().decode("utf-8")
deactivate_path = join(dirname(activate_path), "deactivate")
开发者ID:ARF1,项目名称:conda,代码行数:29,代码来源:test_activate.py
注:本文中的tests.helpers.run_in函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论