has_callback options cannot be overrided

This commit is contained in:
gwen 2012-09-18 15:25:35 +02:00
parent 1ce8d4c098
commit c70fc04f3a
4 changed files with 9 additions and 2 deletions

View File

@ -71,12 +71,16 @@ def test_has_callback():
# here the owner is 'default' # here the owner is 'default'
config = Config(descr, bool=False) config = Config(descr, bool=False)
# because dummy has a callback # because dummy has a callback
dummy = config.unwrap_from_path('gc.dummy')
dummy.freeze()
raises(TypeError, "config.gc.dummy = True") raises(TypeError, "config.gc.dummy = True")
#____________________________________________________________ #____________________________________________________________
def test_has_callback_with_setoption(): def test_has_callback_with_setoption():
descr = make_description() descr = make_description()
config = Config(descr, bool=False) config = Config(descr, bool=False)
dummy = config.unwrap_from_path('gc.dummy')
dummy.freeze()
raises(TypeError, "config.gc.setoption('dummy', True, 'gen_config')") raises(TypeError, "config.gc.setoption('dummy', True, 'gen_config')")
def test_cannot_override(): def test_cannot_override():

View File

@ -101,8 +101,8 @@ def test_group_is_hidden():
descr = make_description() descr = make_description()
config = Config(descr) config = Config(descr)
gc = config.unwrap_from_path('gc') gc = config.unwrap_from_path('gc')
gc.hide()
dummy = config.unwrap_from_path('gc.dummy') dummy = config.unwrap_from_path('gc.dummy')
gc.hide()
raises(PropertiesOptionError, "config.gc.dummy") raises(PropertiesOptionError, "config.gc.dummy")
assert gc._is_hidden() assert gc._is_hidden()
raises(PropertiesOptionError, "config.gc.float") raises(PropertiesOptionError, "config.gc.float")

View File

@ -39,7 +39,7 @@ def test_root_config_answers_ok():
boolop = BoolOption('boolop', 'Test boolean option op', default=True) boolop = BoolOption('boolop', 'Test boolean option op', default=True)
descr = OptionDescription('tiramisu', '', [gcdummy, boolop]) descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
cfg = Config(descr) cfg = Config(descr)
cfg.cfgimpl_hide() cfg.cfgimpl_enable_property('hiddend') #cfgimpl_hide()
assert cfg.dummy == False assert cfg.dummy == False
assert cfg.boolop == True assert cfg.boolop == True

View File

@ -337,6 +337,9 @@ class Config(object):
else: else:
newowner = who newowner = who
if type(child) != SymLinkOption: if type(child) != SymLinkOption:
if child.has_callback():
raise TypeError("trying to set a value to an option "
"wich has a callback: {0}".format(name))
# if oldowner == who: # if oldowner == who:
# oldvalue = getattr(self, name) # oldvalue = getattr(self, name)
# if oldvalue == value: # if oldvalue == value: