Пример #1
0
    def test_create_parser(self):
        """Tests vars_to_optparser create the OptParser if none are given
        """

        self.assertTrue(
            isinstance(vars_to_optparser([]), optparse.OptionParser)
            )
Пример #2
0
    def test_pep8_var_name(self):
        """Tests long string formatting of options added by vars_to_optparser.

        All lower case with hyphen instead of underscore

        """
        parser = vars_to_optparser([Var('Foo'), Var('foo_bar')])
        self.assertEqual(parser.get_option('--foo').dest, 'Foo')
        self.assertEqual(parser.get_option('--foo-bar').dest, 'foo_bar')
Пример #3
0
    def test_pep8_var_name(self):
        """Tests long string formatting of options added by vars_to_optparser.

        All lower case with hyphen instead of underscore

        """
        parser = vars_to_optparser([Var('Foo'), Var('foo_bar')])
        self.assertEqual(parser.get_option('--foo').dest, 'Foo')
        self.assertEqual(parser.get_option('--foo-bar').dest, 'foo_bar')
Пример #4
0
    def configure_parser(self):
        """Configure parser for Skeleton.cmd().
        """
        parser = optparse.OptionParser(usage="%prog [options] dst_dir")
        parser.add_option("-q", "--quiet",
            action="store_const", const=logging.FATAL, dest="verbose_")
        parser.add_option("-v", "--verbose",
            action="store_const", const=logging.INFO, dest="verbose_")
        parser.add_option("-d", "--debug",
            action="store_const", const=logging.DEBUG, dest="verbose_")
        parser.set_default('verbose_', logging.ERROR)

        parser = vars_to_optparser(self.variables, parser=parser)
        return parser
Пример #5
0
    def configure_parser(self):
        """Configure parser for Skeleton.cmd().
        """
        parser = optparse.OptionParser(usage="%prog [options] dst_dir")
        parser.add_option("-q", "--quiet",
            action="store_const", const=logging.FATAL, dest="verbose_")
        parser.add_option("-v", "--verbose",
            action="store_const", const=logging.INFO, dest="verbose_")
        parser.add_option("-d", "--debug",
            action="store_const", const=logging.DEBUG, dest="verbose_")
        parser.set_default('verbose_', logging.ERROR)

        parser = vars_to_optparser(self.variables, parser=parser)
        return parser
Пример #6
0
 def test_default_metavar(self):
     """Tests option's metavar"""
     parser = vars_to_optparser([Var('Foo'), Var('bar_name')])
     self.assertEqual(parser.get_option('--foo').metavar, 'FOO')
     self.assertEqual(parser.get_option('--bar-name').metavar, 'NAME')
Пример #7
0
 def test_augment_parser(self):
     """Tests vars_to_optparser augment the parser given as argument
     """
     parser = optparse.OptionParser()
     self.assertTrue(vars_to_optparser([], parser) is parser)
Пример #8
0
    def test_create_parser(self):
        """Tests vars_to_optparser create the OptParser if none are given
        """

        self.assertTrue(
            isinstance(vars_to_optparser([]), optparse.OptionParser))
Пример #9
0
 def test_default_metavar(self):
     """Tests option's metavar"""
     parser = vars_to_optparser([Var('Foo'), Var('bar_name')])
     self.assertEqual(parser.get_option('--foo').metavar, 'FOO')
     self.assertEqual(parser.get_option('--bar-name').metavar, 'NAME')
Пример #10
0
 def test_augment_parser(self):
     """Tests vars_to_optparser augment the parser given as argument
     """
     parser = optparse.OptionParser()
     self.assertTrue(vars_to_optparser([], parser) is parser)