def parse_args(args): """Parse command line arguments. :param args: List of configure functions functions :type list: [str1, str2,...] List of command line arguments :returns: Parsed arguments :rtype: Namespace """ parser = argparse.ArgumentParser() parser.add_argument('-t', '--tests', nargs='+', help='Space separated list of test classes', required=False) cli_utils.add_model_parser(parser) parser.add_argument('--log', dest='loglevel', help='Loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]') cli_utils.add_test_directory_argument(parser) parser.add_argument('-c', '--config', nargs='+', help=('tests_options config item (e.g. ' 'openstack-upgrade.detect-charm=octavia - repeat' ' as needed.')) parser.set_defaults(loglevel='INFO') return parser.parse_args(args)
def test_parser_model_map(self): parser = argparse.ArgumentParser() cli_utils.add_model_parser(parser) result = parser.parse_args([ '-m', 'modalias1:model1']) self.assertEqual( result.model, {'modalias1': 'model1'})
def test_parser_single_models(self): parser = argparse.ArgumentParser() cli_utils.add_model_parser(parser) result = parser.parse_args([ '--models', 'model1']) self.assertEqual( result.model, {'default_alias': 'model1'})
def parse_args(args): """Parse command line arguments. :param args: List of configure functions functions :type list: [str1, str2,...] List of command line arguments :returns: Parsed arguments :rtype: Namespace """ parser = argparse.ArgumentParser() parser.add_argument('-t', '--tests', nargs='+', help='Space separated list of test classes', required=False) cli_utils.add_model_parser(parser) parser.add_argument('--log', dest='loglevel', help='Loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]') parser.set_defaults(loglevel='INFO') return parser.parse_args(args)