Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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
        )
Exemplo n.º 4
0
 def test_docstring_desc_with_none(self):
     """
     Test _docstring_desc with None.
     """
     description = ArgParser._docstring_desc(None)
     self.assertEqual('', description)
Exemplo n.º 5
0
 def test_docstring_desc_with_empty_string(self):
     """
     Test _docstring_desc with an empty docstring.
     """
     description = ArgParser._docstring_desc('')
     self.assertEqual('', description)
Exemplo n.º 6
0
 def test_docstring_args_with_none(self):
     """
     Test _docstring_args with None (no docstring in function).
     """
     args = ArgParser._docstring_args(None)
     self.assertEqual({}, args)
Exemplo n.º 7
0
 def test_docstring_args_with_empty_string(self):
     """
     Test _docstring_args with an empty docstring.
     """
     args = ArgParser._docstring_args("")
     self.assertEqual({}, args)
Exemplo n.º 8
0
 def parse(self):
     """
     Parse command argument.
     """
     commands = {'create_project': self.create_project}
     ArgParser({'description': 'DataF CLI.'}, commands).parse()