本文整理汇总了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))