diff --git a/test/test_config.py b/test/test_config.py index a5e7b75..997e660 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -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')) +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(): # g1 = IntOption('g1', '', 1) # g2 = StrOption('g2', '', 'héhé') diff --git a/tiramisu/value.py b/tiramisu/value.py index 3d1659b..fc0f12e 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -115,6 +115,9 @@ class Values(object): value, setting_properties, config_bag.properties) + if isinstance(value, list): + # return a copy, so value cannot be modified + return value.copy() # and return it return value