def test_run(self): opts, args = main_parser.parse_args(['issue.ls', '-n', '5']) SUCCESS = self.command.SUCCESS with patch.object(IssueCommand, 'get_repo'): with patch.object(self.command.repo, 'issue') as issue: issue.return_value = self.issue assert self.command.run(opts, args[1:]) == SUCCESS
def main(): opts, args = main_parser.parse_args() if opts.help and not args: args = ['help'] if not args: main_parser.error('You must provide a command. ' '(Use `gh help` to see a list of commands)') repository = () if opts.repository and '/' in opts.repository: repository = opts.repository.split('/', 1) if opts.loc_aware and not repository: repository = get_repository_tuple() command = args[0].lower() load_command(command) status = 1 if command in commands: commands[command].repository = repository status = commands[command].run(opts, args[1:]) if status == commands[command].COMMAND_UNKNOWN: print('Unknown subcommand or option.') commands[command].help() sys.exit(status)
def main(): opts, args = main_parser.parse_args() if opts.help and not args: args = ['help'] if not args: main_parser.error('You must give a command. ' '(Use `gh help` to see a list of commands)') repository = () if opts.repository and '/' in opts.repository: repository = opts.repository.split('/', 1) if opts.loc_aware and not repository: repository = get_repository_tuple() command = args[0].lower() load_command(command) status = 1 if command in commands: commands[command].repository = repository status = commands[command].run(opts, args[1:]) if status == commands[command].COMMAND_UNKNOWN: print('Unknown subcommand or option.') commands[command].help() else: main_parser.error('No such command "{0}"'.format(command)) sys.exit(status)
def test_run(self): opts, args = main_parser.parse_args(['issue', '30', 'comments']) SUCCESS = self.command.SUCCESS FAILURE = self.command.FAILURE with patch.object(IssueCommand, 'get_repo'): with patch.object(self.command.repo, 'issue') as issue: issue.return_value = self.issue assert self.command.run(opts, args[1:]) == SUCCESS assert self.command.run(opts, ['foo']) == FAILURE
def test_run(self): opts, args = main_parser.parse_args(['issues', '30', 'comments']) SUCCESS = self.command.SUCCESS COMMAND_UNKNOWN = self.command.COMMAND_UNKNOWN with patch.object(IssuesCommand, 'get_repo'): with patch.object(self.command.repo, 'issue') as issue: issue.return_value = self.issue assert self.command.run(opts, args[1:]) == SUCCESS assert self.command.run(opts, ['foo']) == COMMAND_UNKNOWN
def test_main_parser(self): opts, args = main_parser.parse_args(['-h']) assert opts.help is True