has_callback options cannot be overrided
authorgwen <gremond@cadoles.com>
Tue, 18 Sep 2012 13:25:35 +0000 (15:25 +0200)
committergwen <gremond@cadoles.com>
Tue, 18 Sep 2012 13:25:35 +0000 (15:25 +0200)
test/test_option_owner.py
test/test_option_type.py
test/test_option_with_special_name.py
tiramisu/config.py

index d7d5ef2..bf29f92 100644 (file)
@@ -71,12 +71,16 @@ def test_has_callback():
     # here the owner is 'default'
     config = Config(descr, bool=False)
     # because dummy has a callback 
+    dummy = config.unwrap_from_path('gc.dummy')
+    dummy.freeze()
     raises(TypeError, "config.gc.dummy = True")
 
 #____________________________________________________________
 def test_has_callback_with_setoption():
     descr = make_description()
     config = Config(descr, bool=False)
+    dummy = config.unwrap_from_path('gc.dummy')
+    dummy.freeze()
     raises(TypeError, "config.gc.setoption('dummy', True, 'gen_config')")
 
 def test_cannot_override():
index 2353656..6a67b50 100644 (file)
@@ -101,8 +101,8 @@ def test_group_is_hidden():
     descr = make_description()
     config = Config(descr)
     gc = config.unwrap_from_path('gc')
-    gc.hide()
     dummy = config.unwrap_from_path('gc.dummy')
+    gc.hide()
     raises(PropertiesOptionError, "config.gc.dummy")
     assert gc._is_hidden()
     raises(PropertiesOptionError, "config.gc.float")
index d606e73..e64c208 100644 (file)
@@ -39,7 +39,7 @@ def test_root_config_answers_ok():
     boolop = BoolOption('boolop', 'Test boolean option op', default=True)
     descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
     cfg = Config(descr)
-    cfg.cfgimpl_hide()
+    cfg.cfgimpl_enable_property('hiddend') #cfgimpl_hide()
     assert cfg.dummy == False
     assert cfg.boolop  == True
     
index 0a44610..799954c 100644 (file)
@@ -337,6 +337,9 @@ class Config(object):
                 else:
                     newowner = who 
         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:
 #                oldvalue = getattr(self, name)
 #                if oldvalue == value: