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')
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)
def test_int(self): cfg = Config() cfg._define('test', 0, validate_int) cfg._set('test', '100') self.assertEqual(cfg.test, 100)
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')