support context param in picklisation

This commit is contained in:
Emmanuel Garette 2015-10-30 22:49:57 +01:00
parent a0de1109f7
commit 2cdd80b83d
2 changed files with 4 additions and 3 deletions

View File

@ -98,7 +98,7 @@ def _diff_opt(opt1, opt2):
if v[1] is not None: if v[1] is not None:
for key, values in v[1].items(): for key, values in v[1].items():
for i, value in enumerate(values): 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][0].impl_getname() == val2[idx][1][key][i][0].impl_getname()
assert v[1][key][i][1] == val2[idx][1][key][i][1] assert v[1][key][i][1] == val2[idx][1][key][i][1]
else: else:
@ -213,7 +213,8 @@ def test_diff_opt_callback():
b = BoolOption('b', '', callback=return_value) b = BoolOption('b', '', callback=return_value)
b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)}) b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)}) 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 = OptionDescription('o1', '', [o])
o1.impl_build_cache_consistency() o1.impl_build_cache_consistency()
o1.impl_build_cache_option() o1.impl_build_cache_option()

View File

@ -231,7 +231,7 @@ class BaseOption(Base):
for key, values in callback_params.items(): for key, values in callback_params.items():
vls = [] vls = []
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple) and value[0] is not None:
if load: if load:
value = (descr.impl_get_opt_by_path(value[0]), value = (descr.impl_get_opt_by_path(value[0]),
value[1]) value[1])