class TestConfigParser(unittest.TestCase): def setUp(self): self.cfg = ConfigParser() def test_parsetok(self): self.cfg.parse(INITOK) conf = self.cfg.get_config() opt = self.cfg.get_options() res = self.cfg.get_resources() self.assertEqual(len(conf), 3) self.assertEqual(len(opt), 1) self.assertEqual(len(res), 1) self.assertEqual(conf['id'], "tok") def test_parsemomel(self): self.cfg.parse(INIMOMEL) conf = self.cfg.get_config() opt = self.cfg.get_options() res = self.cfg.get_resources() self.assertEqual(len(conf), 3) self.assertEqual(len(opt), 9) self.assertEqual(len(res), 0)
def parse(self, filename): p = ConfigParser() p.parse( filename ) self.options = p.get_options() self.langres = p.get_resources() conf = p.get_config() self.key = conf['id'] self.name = conf.get('name', "") self.descr = conf.get('descr', "")