possibility to reset a value

This commit is contained in:
gwen 2012-06-29 10:46:12 +02:00
parent 274192a30b
commit 99b117e838
2 changed files with 9 additions and 1 deletions

View File

@ -81,7 +81,7 @@ class Option(HiddenBaseType, DisabledBaseType, ModeBaseType):
if who == "default" and value is None:
self.default = None
return
if not self.validate(value):
if value != None and not self.validate(value):
raise ConfigError('invalid value %s for option %s' % (value, name))
if who == "default":
# changes the default value (and therefore resets the previous value)

View File

@ -34,6 +34,14 @@ def test_base_config():
dm = cfg.unwrap_from_path('dummy')
assert dm._name == 'dummy'
def test_toto():
descr = make_description()
cfg = Config(descr)
assert cfg.gc.dummy == False
cfg.gc.dummy = True
assert cfg.gc.dummy == True
cfg.gc.dummy = None
def test_base_config_and_groups():
descr = make_description()
# overrides the booloption default value