本文整理匯總了Python中rpg.command.Command.execute_from方法的典型用法代碼示例。如果您正苦於以下問題:Python Command.execute_from方法的具體用法?Python Command.execute_from怎麽用?Python Command.execute_from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpg.command.Command
的用法示例。
在下文中一共展示了Command.execute_from方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_command_execute_from
# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute_from [as 別名]
def test_command_execute_from(self):
cmd = Command("pwd\ncd c\npwd")
output = cmd.execute_from(self.test_project_dir)
path = self.test_project_dir.resolve()
expected = "%s\n%s/c\n" % (path, path)
self.assertEqual(expected, output)
# doesn't add 'cd work_dir' during execute to command lines
cur_dir = Path('.')
with self.assertRaises(subprocess.CalledProcessError) as ctx:
cmd.execute_from(cur_dir)
expected = "Command '['/bin/sh', '-c', 'cd %s && pwd && cd c && pwd" \
"']' returned non-zero exit status 1" % cur_dir.resolve()
self.assertEqual(expected, str(ctx.exception))