本文整理匯總了Python中invoke.Context.prefix方法的典型用法代碼示例。如果您正苦於以下問題:Python Context.prefix方法的具體用法?Python Context.prefix怎麽用?Python Context.prefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類invoke.Context
的用法示例。
在下文中一共展示了Context.prefix方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: prefixes_should_apply_to_sudo
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def prefixes_should_apply_to_sudo(self, Local):
runner = Local.return_value
c = Context()
with c.prefix("cd foo"):
c.sudo("whoami")
cmd = "sudo -S -p '[sudo] password: ' cd foo && whoami"
assert runner.run.called, "sudo() never called runner.run()!"
assert runner.run.call_args[0][0] == cmd
示例2: prefixes_should_apply_to_sudo
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def prefixes_should_apply_to_sudo(self, Local):
runner = Local.return_value
ctx = Context()
with ctx.prefix('cd foo'):
ctx.sudo('whoami')
cmd = "sudo -S -p '[sudo] password: ' cd foo && whoami"
ok_(runner.run.called, "sudo() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
示例3: prefixes_should_apply_to_run
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def prefixes_should_apply_to_run(self, Local):
runner = Local.return_value
c = Context()
with c.prefix("cd foo"):
c.run("whoami")
cmd = "cd foo && whoami"
assert runner.run.called, "run() never called runner.run()!"
assert runner.run.call_args[0][0] == cmd
示例4: prefixes_should_apply_to_run
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def prefixes_should_apply_to_run(self, Local):
runner = Local.return_value
ctx = Context()
with ctx.prefix('cd foo'):
ctx.run('whoami')
cmd = "cd foo && whoami"
ok_(runner.run.called, "run() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
示例5: cd_should_occur_before_prefixes
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def cd_should_occur_before_prefixes(self, Local):
runner = Local.return_value
c = Context()
with c.prefix("source venv"):
with c.cd("foo"):
c.run("whoami")
cmd = "cd foo && source venv && whoami"
assert runner.run.called, "run() never called runner.run()!"
assert runner.run.call_args[0][0] == cmd
示例6: cd_should_occur_before_prefixes
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def cd_should_occur_before_prefixes(self, Local):
runner = Local.return_value
ctx = Context()
with ctx.prefix('source venv'):
with ctx.cd('foo'):
ctx.run('whoami')
cmd = "cd foo && source venv && whoami"
ok_(runner.run.called, "run() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
示例7: nesting_should_retain_order
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def nesting_should_retain_order(self, Local):
runner = Local.return_value
ctx = Context()
with ctx.prefix('cd foo'):
with ctx.prefix('cd bar'):
ctx.run('whoami')
cmd = "cd foo && cd bar && whoami"
ok_(runner.run.called, "run() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
ctx.run('whoami')
cmd = "cd foo && whoami"
ok_(runner.run.called, "run() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
# also test that prefixes do not persist
ctx.run('whoami')
cmd = "whoami"
ok_(runner.run.called, "run() never called runner.run()!")
eq_(runner.run.call_args[0][0], cmd)
示例8: nesting_should_retain_order
# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import prefix [as 別名]
def nesting_should_retain_order(self, Local):
runner = Local.return_value
c = Context()
with c.prefix('cd foo'):
with c.prefix('cd bar'):
c.run('whoami')
cmd = "cd foo && cd bar && whoami"
assert runner.run.called, "run() never called runner.run()!" # noqa
assert runner.run.call_args[0][0] == cmd
c.run('whoami')
cmd = "cd foo && whoami"
assert runner.run.called, "run() never called runner.run()!"
assert runner.run.call_args[0][0] == cmd
# also test that prefixes do not persist
c.run('whoami')
cmd = "whoami"
assert runner.run.called, "run() never called runner.run()!"
assert runner.run.call_args[0][0] == cmd