示例#1
0
文件: test_command.py 项目: khuno/rpg
    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))
示例#2
0
    def test_command_execute_from(self):
        cmd = Command("pwd\ncd c 2>/dev/null\npwd")
        output = cmd.execute_from(self.test_project_dir)
        path = path_to_str(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 2>/dev/null && pwd']' "\
                   "returned non-zero exit status 1"\
                   % path_to_str(cur_dir.resolve())
        self.assertEqual(expected, str(ctx.exception))