8 |
8 |
9 class TestConfigParser(unittest.TestCase): |
9 class TestConfigParser(unittest.TestCase): |
10 |
10 |
11 def setUp(self): |
11 def setUp(self): |
12 self.config = ConfigParser() |
12 self.config = ConfigParser() |
13 self.config.add_argument('arg_str') |
13 self.config.add_option('arg_str') |
14 self.config.add_argument('arg_int', int, 1) |
14 self.config.add_option('arg_int', int, 1) |
15 script_path = os.path.dirname(os.path.realpath(__file__)) |
15 script_path = os.path.dirname(os.path.realpath(__file__)) |
16 self.data_path = os.path.join(script_path, 'data') |
16 self.data_path = os.path.join(script_path, 'data') |
17 |
17 |
18 def test_add_argument(self): |
18 def test_add_option(self): |
19 name = 'argname' |
19 name = 'argname' |
20 self.config.add_argument(name, int, 1) |
20 self.config.add_option(name, int, 1) |
21 self.assertEqual(self.config.registered_args[name]['type'], int) |
21 self.assertEqual(self.config.options[name]['type'], int) |
22 self.assertEqual(self.config.registered_args[name]['default'], 1) |
22 self.assertEqual(self.config.options[name]['default'], 1) |
23 self.assertEqual(self.config.args[name], 1) |
23 self.assertEqual(self.config.values[name], 1) |
24 |
24 |
25 def test_load_badname(self): |
25 def test_load_badname(self): |
26 self.assertRaises(IOError, self.config.load, 'bad/file_name') |
26 self.assertRaises(IOError, self.config.load, 'bad/file_name') |
27 |
27 |
28 def test_load_badargs(self): |
28 def test_load_badargs(self): |