test force_default_on_freeze with multi and correction in Multi()
authorEmmanuel Garette <egarette@cadoles.com>
Wed, 28 Aug 2013 20:50:35 +0000 (22:50 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Wed, 28 Aug 2013 20:50:35 +0000 (22:50 +0200)
test/test_option_default.py
tiramisu/value.py

index 3f3cf8a..b24d3f1 100644 (file)
@@ -68,6 +68,20 @@ def test_force_default_on_freeze():
     assert config.dummy2 is False
 
 
+def test_force_default_on_freeze_multi():
+    dummy1 = BoolOption('dummy1', 'doc dummy', default=[False], properties=('force_default_on_freeze',), multi=True)
+    dummy2 = BoolOption('dummy2', 'doc dummy', default=[True], multi=True)
+    group = OptionDescription('group', '', [dummy1, dummy2])
+    config = Config(group)
+    config.dummy1.append(True)
+    config.dummy2.append(False)
+    setting = config.cfgimpl_get_settings()
+    setting[dummy1].append('frozen')
+    setting[dummy2].append('frozen')
+    assert config.dummy1 == [False]
+    assert config.dummy2 == [True, False]
+
+
 def test_overrides_changes_option_value():
     "with config.override(), the default is changed and the value is changed"
     descr = OptionDescription("test", "", [
index 6bbce3c..d846bc4 100644 (file)
@@ -205,7 +205,7 @@ class Values(object):
         elif is_frozen and 'force_default_on_freeze' in setting[opt]:
             value = self._getdefault(opt)
             if opt.impl_is_multi():
-                value = Multi(value, self.context(), opt, path, validate)
+                value = Multi(value, self.context, opt, path, validate)
         else:
             value = self._getvalue(opt, path, validate)
         if validate: