possibility to reset a value
This commit is contained in:
parent
274192a30b
commit
99b117e838
2 changed files with 9 additions and 1 deletions
|
@ -81,7 +81,7 @@ class Option(HiddenBaseType, DisabledBaseType, ModeBaseType):
|
||||||
if who == "default" and value is None:
|
if who == "default" and value is None:
|
||||||
self.default = None
|
self.default = None
|
||||||
return
|
return
|
||||||
if not self.validate(value):
|
if value != None and not self.validate(value):
|
||||||
raise ConfigError('invalid value %s for option %s' % (value, name))
|
raise ConfigError('invalid value %s for option %s' % (value, name))
|
||||||
if who == "default":
|
if who == "default":
|
||||||
# changes the default value (and therefore resets the previous value)
|
# changes the default value (and therefore resets the previous value)
|
||||||
|
|
|
@ -34,6 +34,14 @@ def test_base_config():
|
||||||
dm = cfg.unwrap_from_path('dummy')
|
dm = cfg.unwrap_from_path('dummy')
|
||||||
assert dm._name == '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():
|
def test_base_config_and_groups():
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
# overrides the booloption default value
|
# overrides the booloption default value
|
||||||
|
|
Loading…
Reference in a new issue