class MyCmd: logger = ColorPrinter(False, stream=output) @noargs_command def my_cmd(self, *args): return 'awesome'
def test_help_command(self): """Test output of help command""" command = CrateShell(is_tty=False) expected = "\n".join([ '\\? print this help', '\\autocapitalize toggle automatic capitalization of SQL keywords', '\\autocomplete toggle autocomplete', '\\c connect to the given server, e.g.: \\connect localhost:4200', '\\check print failed cluster and/or node checks, e.g. \\check nodes', '\\connect connect to the given server, e.g.: \\connect localhost:4200', '\\dt print the existing tables within the \'doc\' schema', '\\format switch output format', '\\q quit crash', '\\r read and execute statements from a file', '\\sysinfo print system and cluster info', '\\verbose toggle verbose mode', ]) help_ = command.commands['?'] self.assertTrue(isinstance(help_, Command)) self.assertEqual(expected, help_(command)) with CrateShell(is_tty=False) as cmd: output = StringIO() cmd.logger = ColorPrinter(False, stream=output) text = help_(cmd, 'arg1', 'arg2') self.assertEqual(None, text) self.assertEqual('Command does not take any arguments.\n', output.getvalue())
def __init__(self): super(CrateTestShell, self).__init__(is_tty=False) self.logger = ColorPrinter(False, stream=PrintWrapper(), line_end='\n')
def __init__(self, **kwargs): super(CrateTestCmd, self).__init__(**kwargs) doctest_print = PrintWrapper() self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n')