def _create_arg_parser(cls, opt=None, commands=None): """ Create an ArgParser. :param dict opt: options for ArgParser. :param dict commands: commands for ArgParser. """ opt = opt or {'description': 'Test'} commands = commands or {'test': cls._test_command} arg_parser = ArgParser(opt, commands) return arg_parser
def test_docstring_desc(self): """ Test _docstring_desc return first line of docstring. """ description = ArgParser._docstring_desc( """ Test docstring. Second line. :param str test: test string. :param str test2: second test string. """ ) self.assertEqual('Test docstring.', description)
def test_docstring_args(self): """ Test _docstring_args return dict with docstring param as ReStructuredText. """ args = ArgParser._docstring_args( """ Test docstring. :param str test: test string. :param str test2: second test string. """ ) self.assertEqual( {'test': 'test string.', 'test2': 'second test string.'}, args )
def test_docstring_desc_with_none(self): """ Test _docstring_desc with None. """ description = ArgParser._docstring_desc(None) self.assertEqual('', description)
def test_docstring_desc_with_empty_string(self): """ Test _docstring_desc with an empty docstring. """ description = ArgParser._docstring_desc('') self.assertEqual('', description)
def test_docstring_args_with_none(self): """ Test _docstring_args with None (no docstring in function). """ args = ArgParser._docstring_args(None) self.assertEqual({}, args)
def test_docstring_args_with_empty_string(self): """ Test _docstring_args with an empty docstring. """ args = ArgParser._docstring_args("") self.assertEqual({}, args)
def parse(self): """ Parse command argument. """ commands = {'create_project': self.create_project} ArgParser({'description': 'DataF CLI.'}, commands).parse()