support context param in picklisation
authorEmmanuel Garette <egarette@cadoles.com>
Fri, 30 Oct 2015 21:49:57 +0000 (22:49 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Fri, 30 Oct 2015 21:51:24 +0000 (22:51 +0100)
test/test_state.py
tiramisu/option/baseoption.py

index 22931a1..302a58c 100644 (file)
@@ -98,7 +98,7 @@ def _diff_opt(opt1, opt2):
                         if v[1] is not None:
                             for key, values in v[1].items():
                                 for i, value in enumerate(values):
-                                    if isinstance(value, tuple):
+                                    if isinstance(value, tuple) and value[0] is not None:
                                         assert v[1][key][i][0].impl_getname() == val2[idx][1][key][i][0].impl_getname()
                                         assert v[1][key][i][1] == val2[idx][1][key][i][1]
                                     else:
@@ -213,7 +213,8 @@ def test_diff_opt_callback():
     b = BoolOption('b', '', callback=return_value)
     b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
     b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
-    o = OptionDescription('o', '', [b, b2, b3])
+    b4 = BoolOption("b4", "", callback=return_value, callback_params={'': ((None,),), 'value': ('string',)})
+    o = OptionDescription('o', '', [b, b2, b3, b4])
     o1 = OptionDescription('o1', '', [o])
     o1.impl_build_cache_consistency()
     o1.impl_build_cache_option()
index 7895661..410980c 100644 (file)
@@ -231,7 +231,7 @@ class BaseOption(Base):
                 for key, values in callback_params.items():
                     vls = []
                     for value in values:
-                        if isinstance(value, tuple):
+                        if isinstance(value, tuple) and value[0] is not None:
                             if load:
                                 value = (descr.impl_get_opt_by_path(value[0]),
                                          value[1])