def test_execute_command_with_args_options(self): runner = Runner(['test.py', 'runargsoptions', 'test', '-f', 'filename.txt'], commands=[ 'tests.watson.console.support.SampleArgumentsCommand', 'tests.watson.console.support.SampleArgumentsWithOptionsCommand' ]) output = runner.execute() # will print to screen in tests assert output
def test_execute_command_usage(self): runner = Runner(commands=[ 'tests.watson.console.support.SampleStringCommand', SampleNonStringCommand ]) with raises(SystemExit): runner.execute(['test.py', 'nonstring', 'execute', '-h']) # will print to screen in tests
def test_execute_command_usage(self): runner = Runner(['test.py', 'nonstring', '-h'], commands=[ 'tests.watson.console.support.SampleStringCommand', SampleNonStringCommand ]) output = runner.execute() # will print to screen in tests assert not output
def test_no_execute(self): runner = Runner( ['test.py', 'nohelpnoexecute'], commands=[ 'tests.watson.console.support.SampleNoHelpNoExecuteCommand' ]) runner.execute()
def test_add_commands(self): runner = Runner() assert len(runner.commands) == 0 runner.add_commands( [SampleNonStringCommand, 'tests.watson.console.support.SampleStringCommand']) assert len(runner.commands) == 2 assert not runner.get_command('test')
def test_add_commands(self): runner = Runner() assert len(runner.commands) == 0 runner.add_commands([ SampleNonStringCommand, 'tests.watson.console.support.SampleStringCommand' ]) assert len(runner.commands) == 2 assert not runner.get_command('test')
def __init__(self, config=None, argv=None): super(Console, self).__init__(config) self.config = dict_deep_update( {'commands': find_commands_in_module(DefaultConsoleCommands)}, self.config) self.runner = Runner(argv, commands=self.config.get('commands')) self.runner.get_command = self.get_command
def test_create(self): runner = Runner(['test.py'], commands=[ 'tests.watson.console.support.SampleStringCommand', SampleNonStringCommand ]) assert len(runner.commands) == 2 assert runner.name == 'test.py'
def test_execute_command_with_args(self): runner = Runner( ['test.py', 'runargs', 'test', 'test2'], commands=['tests.watson.console.support.SampleArgumentsCommand']) output = runner.execute() # will print to screen in tests assert output
def test_execute_command(self): runner = Runner( ['test.py', 'nonstring'], commands=['tests.watson.console.support.SampleNonStringCommand']) assert runner()
def test_execute_command_with_options(self): runner = Runner( ['test.py', 'runoptions', '-f', 'test'], commands=['tests.watson.console.support.SampleOptionsCommand']) output = runner.execute() # will print to screen in tests assert output
def test_no_execute(self): with raises(SystemExit): runner = Runner(commands=[ 'tests.watson.console.support.SampleNoHelpNoExecuteCommand' ]) runner.execute(['test.py', 'nohelpnoexecute', 'execute'])
def test_execute_command_with_error(self): runner = Runner( ['test.py', 'string'], commands=['tests.watson.console.support.SampleStringCommand']) runner()
def test_execute_command_usage_with_args(self): runner = Runner(commands=[ 'tests.watson.console.support.SampleArgumentsCommand' ]) with raises(SystemExit): runner.execute(['test.py', 'runargs', 'execute', '-h']) # will print to screen in tests
def test_execute_command_with_args(self): runner = Runner(['test.py', 'runargs', 'test', 'test2'], commands=[ 'tests.watson.console.support.SampleArgumentsCommand' ]) output = runner.execute() # will print to screen in tests assert output
def test_execute_command_with_options(self): runner = Runner(['test.py', 'runoptions', '-f', 'test'], commands=[ 'tests.watson.console.support.SampleOptionsCommand' ]) output = runner.execute() # will print to screen in tests assert output
def test_execute_command_with_options_invalid(self): runner = Runner(commands=[ 'tests.watson.console.support.SampleOptionsCommand' ]) with raises(SystemExit): runner.execute(['test.py', 'runoptions', 'execute', '-d']) # will print to screen in tests
def test_no_execute(self): with raises(TypeError): runner = Runner(['test.py', 'nohelpnoexecute'], commands=[ 'tests.watson.console.support.SampleNoHelpNoExecuteCommand' ]) runner.execute()