Пример #1
0
 def test_add_arg_with_argumentparser(self):
     """add_arg works with ArgumentParser
     """
     p = ArgumentParser()
     add_arg(p, '-n', action='store', dest='n')
     args = p.parse_args(['-n', '4'])
     self.assertEqual(args.n, '4')
Пример #2
0
 def test_add_arg_with_argumentparser(self):
     """add_arg works with ArgumentParser argument group
     """
     p = ArgumentParser()
     g = p.add_argument_group('Suboptions')
     add_arg(g, '-n', action='store', dest='n')
     args = p.parse_args(['-n', '4'])
     self.assertEqual(args.n, '4')
Пример #3
0
 def test_add_arg_with_optionparser(self):
     """add_arg works with OptionParser
     """
     # Skip the test if optparse not available
     if not OPTPARSE_AVAILABLE:
         raise unittest.SkipTest("'optparse' not available")
     p = OptionParser()
     add_arg(p, '-n', action='store', dest='n')
     options, args = p.parse_args(['-n', '4'])
     self.assertEqual(options.n, '4')