Exemple #1
0
 def test_add_positional_parameter_with_options(self, parameter_name,
                                                input_value, return_value):
     parser = commandline.ArgumentParser()
     getattr(parser, "add_" + parameter_name)({'command': {'param': 5}})
     args = parser.parse_args([input_value, '--param', '5'])
     self.assertEqual(getattr(args, parameter_name), return_value)
     self.assertEqual(getattr(args, 'param'), 5)
Exemple #2
0
 def test_init(self):
     commandline.ArgumentParser('description')
Exemple #3
0
 def test_wrong_argument(self):
     parser = commandline.ArgumentParser()
     with self.assertRaises(SystemExit):
         parser.parse_args(['--nogoodargument', 'unittest'])
Exemple #4
0
 def test_add_arguments_by_name(self):
     parser = commandline.ArgumentParser()
     parser.add_arguments_by_name("word")
     args = parser.parse_args(['--word', 'd'])
     self.assertEqual(args.word, 'd')
Exemple #5
0
 def test_add_positional_parameter(self, parameter_name, input_value,
                                   return_value):
     parser = commandline.ArgumentParser()
     getattr(parser, "add_" + parameter_name)()
     args = parser.parse_args([input_value])
     self.assertEqual(getattr(args, parameter_name), return_value)