def test0_read(self): self.write(self.string1, self.tempf) _cfg = Configuration() self.assertRaises(ValueError, _cfg.read, self.tempf) self.write(self.string2, self.tempf) _cfg.clear() self.assertEqual(None, _cfg.read(self.tempf))
def test2_get_config_simulation(self): _cfg = Configuration() _cfg.read(self.tempf) self.assertRaises(ValueError, _cfg.get_config, "simulation") self.string2 = re.sub(r"= mode", r"= simulation", self.string2) self.write(self.string2, self.tempf) _cfg.clear() _cfg.read(self.tempf) self.assertTrue("path" in _cfg.get_config("simulation"))
def test3_get_config_properties(self): _cfg = Configuration() _cfg.read(self.tempf) # totalProperties self.assertRaises(ValueError, _cfg.get_config, "properties") self.string2 = re.sub(r"= total.*", r"= 0", self.string2) self.write(self.string2, self.tempf) _cfg.clear() _cfg.read(self.tempf) self.assertRaises(ValueError, _cfg.get_config, "properties") more_configs = (r"= 1\n" r"property1Name = \n" r"property1Ref = 1\n") self.string2 = re.sub(r"= 0", more_configs, self.string2) self.write(self.string2, self.tempf) _cfg.clear() _cfg.read(self.tempf) self.assertEqual([1.0], _cfg.get_config("properties")[2])