when list, return a list

This commit is contained in:
Emmanuel Garette 2018-07-22 11:51:48 +02:00
parent d0f6a4dd31
commit e3be95a274
2 changed files with 15 additions and 0 deletions

View file

@ -251,6 +251,18 @@ def test_get_modified_values():
assert to_tuple(api.value.exportation()) == (('od.g5', 'od.g6'), (None, None), ('yes', tuple()), ('user', 'user')) assert to_tuple(api.value.exportation()) == (('od.g5', 'od.g6'), (None, None), ('yes', tuple()), ('user', 'user'))
def test_get_modified_values_not_modif():
g1 = StrOption('g1', '', multi=True)
d1 = OptionDescription('od', '', [g1])
root = OptionDescription('root', '', [d1])
config = Config(root)
api = getapi(config)
assert api.option('od.g1').value.get() == []
value = api.option('od.g1').value.get()
value.append('val')
assert api.option('od.g1').value.get() == []
#def test_has_value(): #def test_has_value():
# g1 = IntOption('g1', '', 1) # g1 = IntOption('g1', '', 1)
# g2 = StrOption('g2', '', 'héhé') # g2 = StrOption('g2', '', 'héhé')

View file

@ -115,6 +115,9 @@ class Values(object):
value, value,
setting_properties, setting_properties,
config_bag.properties) config_bag.properties)
if isinstance(value, list):
# return a copy, so value cannot be modified
return value.copy()
# and return it # and return it
return value return value