示例#1
0
 def test_count_default(self):
     cfg = Config()
     cfg._define('a.b.count', 0, validate_int)
     cfg._define('a.b.c', 'bar', counter='a.b.count')
     cfg._set('a.b.count', '2')
     self.assertEqual(cfg.a.b.c[2], 'bar')
     cfg._set('a.b.c.2', 'foo')
     self.assertEqual(cfg.a.b.c[2], 'foo')
示例#2
0
 def test_file(self):
     cfg = Config()
     cfg._define('test', validator=validate_file)
     data = os.path.splitext(inspect.getfile(self.__class__))[0] + '.txt'
     cfg._set('test', data)
     self.assertEqual(cfg.test, data)
示例#3
0
 def test_int(self):
     cfg = Config()
     cfg._define('test', 0, validate_int)
     cfg._set('test', '100')
     self.assertEqual(cfg.test, 100)
示例#4
0
 def test_reset(self):
     cfg = Config()
     cfg._define('a.b.c', 'nothing')
     self.assertEqual(cfg.a.b.c, 'nothing')
     cfg._set('a.b.c', 'something')
     self.assertEqual(cfg.a.b.c, 'something')
示例#5
0
 def test_file(self):
     cfg = Config()
     cfg._define('test', validator=validate_file)
     data = os.path.splitext(inspect.getfile(self.__class__))[0] + '.txt'
     cfg._set('test', data)
     self.assertEqual(cfg.test, data)
示例#6
0
 def test_int(self):
     cfg = Config()
     cfg._define('test', 0, validate_int)
     cfg._set('test', '100')
     self.assertEqual(cfg.test, 100)
示例#7
0
 def test_reset(self):
     cfg = Config()
     cfg._define('a.b.c', 'nothing')
     self.assertEqual(cfg.a.b.c, 'nothing')
     cfg._set('a.b.c', 'something')
     self.assertEqual(cfg.a.b.c, 'something')