def testExecuteCommand(self): def Cmd(console_, subject='World'): console_.Print('Hello, %s!' % subject) app = App('test', color=False, buffered_console=True) app.Add(Cmd) retcode, output = app.ExecuteCommand('cmd') assert retcode == app.RETCODE_OK assert output == 'Hello, World!\n' retcode, output = app.ExecuteCommand('cmd', 'Alpha') assert retcode == app.RETCODE_OK assert output == 'Hello, Alpha!\n'
def testCommandDecorator(self): app = App('test', color=False, buffered_console=True) @app def Alpha(console_): console_.Print('Alpha') @app() def Bravo(console_): console_.Print('Bravo') assert app.ExecuteCommand('alpha') == (app.RETCODE_OK, 'Alpha\n') assert app.ExecuteCommand('bravo') == (app.RETCODE_OK, 'Bravo\n')