示例#1
0
 def test_Singleton(self):
     utcfg = UTConfig.UTConfig()
     ut2 = UTConfig.UTConfig()
     self.assertTrue(utcfg == ut2)
     utcfg.LoadFile('exp.cfg')
     paths = utcfg.GetSearchPaths()
     self.assertTrue('/nopath' in paths)
     ut2.LoadFile('inc.cfg')
     paths = ut2.GetSearchPaths()
     self.assertTrue('/nopath' in paths)
     ut2.SetValue('no_section', 'no_opt', 'no_value')
     v = utcfg.GetValue('no_section', 'no_opt')
     self.assertEqual(v, 'no_value')
     return
示例#2
0
 def test_Unittests(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     units = utcfg.GetUnitTests()
     self.assertTrue('base.unit.test' in units)
     self.assertTrue('inc.unit.test' in units)
     self.assertTrue(len(units) == 2)
     return
示例#3
0
 def test_IncludeFiles(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     includes = utcfg.GetIncludeFiles()
     self.assertTrue('inc.cfg' in includes)
     self.assertTrue('base.cfg' in includes)
     #self.assertTrue(len(includes) == 2)
     return
示例#4
0
 def test_LoadError(self):
     ok = 1
     try:
         utcfg = UTConfig.UTConfigBase()
         utcfg.LoadFile('nocfg.cfg')
     except UTConfig.UTCfgLoadFileError as e:
         ok = 0
     self.assertTrue(ok == 0)
     return
示例#5
0
 def test_SectionInnerOverflowError(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     ok = 1
     try:
         v = utcfg.GetValue('valuebase', 'base1')
     except UTConfig.UTCfgOverflowError as e:
         ok = 0
     self.assertTrue(ok == 0)
     return
示例#6
0
 def test_LoadBasic(self):
     # now for
     utcfg = UTConfig.UTConfigBase('base.cfg')
     self.assertEqual(utcfg.GetValue('new', 'base2'), 'hello world')
     return
示例#7
0
 def test_setgetvalue(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     utcfg.SetValue('base2.value', 'base4', '%(base2.value.base2)s value')
     v = utcfg.GetValue('base2.value', 'base4')
     self.assertEqual(v, 'hello param1 value')
     return
示例#8
0
 def test_noref(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     v = utcfg.GetValue('base2.value', 'base3')
     self.assertEqual(v, ' param1')
     return
示例#9
0
 def test_3LevelRef(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     v = utcfg.GetValue('base2.value', 'base2')
     self.assertEqual(v, 'hello param1')
     return
示例#10
0
 def test_NonValue(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     v = utcfg.GetValue('no_section', 'no_opt')
     self.assertTrue(v == '')
     return
示例#11
0
 def test_SearchPaths(self):
     utcfg = UTConfig.UTConfigBase('inc.cfg')
     paths = utcfg.GetSearchPaths()
     self.assertTrue(len(paths) == 1)
     self.assertTrue('inc' in paths)
     return
示例#12
0
 def test_SearchPathNoRef(self):
     utcfg = UTConfig.UTConfigBase()
     utcfg.LoadFile('exp.cfg')
     paths = utcfg.GetSearchPaths()
     self.assertTrue('/nopath' in paths)
     return
示例#13
0
 def test_SearchPathExp(self):
     utcfg = UTConfig.UTConfigBase()
     utcfg.LoadFile('exp.cfg')
     paths = utcfg.GetSearchPaths()
     self.assertTrue('/usr/inc' in paths)
     return