def test_create_parser(self): """Tests vars_to_optparser create the OptParser if none are given """ self.assertTrue( isinstance(vars_to_optparser([]), optparse.OptionParser) )
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')
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
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')
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)
def test_create_parser(self): """Tests vars_to_optparser create the OptParser if none are given """ self.assertTrue( isinstance(vars_to_optparser([]), optparse.OptionParser))