Пример #1
0
 def test_save(self):
     '''Verify save functionality works'''
     pp1 = PP(self.fqtest, woc=False)
     pp1.set("unsaved_value", 42)
     pp1.save(path=self.fqsave)
     pp2 = PP(self.fqsave)
     self.assertEqual(pp1.settings, pp2.settings)
     remove(self.fqsave)
Пример #2
0
    def test_woc_and_lofc(self):
        '''Verify woc and lofc option functionality works'''
        copyfile(self.fqtest, self.fqwoc)
        copyfile(self.fqtest, self.fqsave)
        pp_orig = PP(self.fqsave, lofc=True)
        pp1 = PP(self.fqwoc, lofc=True)

        pp2 = PP(self.fqwoc, woc=True, lofc=True)
        pp2['woc_value1'] = 1

        del(pp2['woc_value1'])

        pp2.set('woc_value2', 2)
        pp2.save()

        pp1['woc_value2']

        sleep(.1)
        copyfile(self.fqwoc, self.fqsave)
        pp_orig.get('woc_value2')

        remove(self.fqwoc)
        remove(self.fqsave)
Пример #3
0
 def test_reload(self):
     '''Verify reload functionality works'''
     pp = PP(self.fqtest, woc=False)
     pp.set("unsaved_value", 42)
     pp.reload()
     self.assertRaises(KeyError, pp.get, "unsaved_value")
Пример #4
0
 def test_borg(self):
     '''Verify borg functionality works (simple singleton)'''
     pp1 = PP(self.fqtest, woc=False)
     pp2 = PP(self.fqtest, woc=False)
     pp1.set("unsaved_value", 42)
     self.assertEqual(pp1.get("unsaved_value"), pp2.get("unsaved_value"))
Пример #5
0
 def test_get(self):
     '''Verify get method functionality'''
     pp = PP(self.fqtest)
     self.assertEqual(pp.get("setting1"), "value1")
     self.assertEqual(pp.get("setting 2"), 2)
     self.assertEqual(pp.get("section1"), {'subsetting1': 'subvalue2'})