def testPositionalArgs(self): ''' >test command alpha bravo alpha..bravo ''' app = App('test', color=False, buffered_console=True) def Command(console_, first, second): console_.Print('%s..%s' % (first, second)) app.Add(Command) app.TestScript(inspect.getdoc(self.testPositionalArgs))
def testBoolArgFalse(self): ''' >test command False >test command --option True ''' app = App('test', color=False, buffered_console=True) def Command(console_, option=False): console_.Print(option) app.Add(Command) app.TestScript(inspect.getdoc(self.testBoolArgFalse))
def testOptionUnderscore(self): ''' >test command my_option = default >test command --my-option=custom my_option = custom ''' app = App('test', color=False, buffered_console=True) def Command(console_, my_option='default'): console_.Print('my_option = ' + my_option) app.Add(Command) app.TestScript(inspect.getdoc(self.testOptionUnderscore))
def testOptionArgs(self): ''' >test command 1..2 >test command --first=alpha --second=bravo alpha..bravo ''' app = App('test', color=False, buffered_console=True) def Command(console_, first='1', second='2'): console_.Print('%s..%s' % (first, second)) app.Add(Command) app.TestScript(inspect.getdoc(self.testOptionArgs))
def testConsolePluginNoColor(self): ''' >test command console.color = False >test command --no-color console.color = False ''' app = App('test', color=False, buffered_console=True) def Command(console_): console_.Print('console.color = %s' % console_.color) app.Add(Command) app.TestScript(inspect.getdoc(self.testConsolePluginNoColor))
def testPositionalArgsWithDefaults(self): ''' >test hello NOTHING >test hello something something ''' app = App('test', color=False, buffered_console=True) def Hello(console_, message=App.DEFAULT('NOTHING')): console_.Print(message) app.Add(Hello) app.TestScript(inspect.getdoc(self.testPositionalArgsWithDefaults))
def testUnknownOptionArgs(self): def Command(console_): '' app = App('test', color=False, buffered_console=True) app.Add(Command) app.TestScript( dedent(''' >test command --foo --bar [retcode=1] ERROR: Unrecognized arguments: --foo --bar (no description) Usage: command\s\s Parameters: Options: '''.replace('\s', ' ')))
def testConsolePluginVerbosity(self): ''' >test command quiet normal >test command --verbose quiet normal verbose >test command --quiet quiet ''' app = App('test', color=False, buffered_console=True) def Command(console_): console_.PrintQuiet('quiet') console_.Print('normal') console_.PrintVerbose('verbose') app.Add(Command) app.TestScript(inspect.getdoc(self.testConsolePluginVerbosity))