Esempio n. 1
0
    def test_error(self):
        c = Config()
        self.failUnlessRaises(KeyError, lambda:c.set("MAJ", 3))
        self.failUnlessRaises(KeyError, lambda:c.get("MAJ"))

        c.load_writable_config_file(pathWritable, pathRef)
        self.failUnlessRaises(KeyError, lambda:c.get("easter"))
Esempio n. 2
0
 def test_save(self):
     shutil.copy(pathWritable, pathTemp)
     c = Config()
     c.load_writable_config_file(pathTemp, pathRef)
     c.set("firstint", 666)
     c.set("liststr", ["1", "2", "3"])
     c.set("listint", [666, 666])
     c.set("lls", [["A"], ["B", "BETA"], ["C", "CETA", "3"]])
     c.save()
     c = Config()
     c.load_writable_config_file(pathTemp, pathRef)
     self.assertEqual(c.get("firstint"), 666)
     self.assertEqual(c.get("liststr"), ["1", "2", "3"])
     self.assertEqual(c.get("listint"), [666, 666])
     self.assertEqual(c.get("lls"), [["A"], ["B", "BETA"], ["C", "CETA", "3"]])
     os.remove(pathTemp)
     
     c = Config()
     c.load_writable_config_file(pathTemp2, pathRef)
     c.set("firstint", 666)
     c.save()
     c.load_writable_config_file(pathTemp2, pathRef)
     self.assertEqual(c.get("firstint"), 666)
     shutil.rmtree("./a")