fix merging references to lists
diff --git a/reclass/datatypes/tests/test_parameters.py b/reclass/datatypes/tests/test_parameters.py
index 5ed85b4..97fb924 100644
--- a/reclass/datatypes/tests/test_parameters.py
+++ b/reclass/datatypes/tests/test_parameters.py
@@ -324,5 +324,20 @@
p1.interpolate()
self.assertEqual(p1.as_dict(), r)
+ def test_merge_referenced_lists(self):
+ p1 = Parameters({'one': [ 1, 2, 3 ], 'two': [ 4, 5, 6 ], 'three': '${one}'})
+ p2 = Parameters({'three': '${two}'})
+ r = {'one': [ 1, 2, 3 ], 'two': [ 4, 5, 6], 'three': [ 1, 2, 3, 4, 5, 6 ]}
+ p1.merge(p2)
+ p1.interpolate()
+ self.assertEqual(p1.as_dict(), r)
+
+ def test_merge_referenced_dicts(self):
+ p1 = Parameters({'one': {'a': 1, 'b': 2}, 'two': {'c': 3, 'd': 4}, 'three': '${one}'})
+ p2 = Parameters({'three': '${two}'})
+ r = {'one': {'a': 1, 'b': 2}, 'two': {'c': 3, 'd': 4}, 'three': {'a': 1, 'b': 2, 'c': 3, 'd': 4}}
+ p1.merge(p2)
+ p1.interpolate()
+ self.assertEqual(p1.as_dict(), r)
if __name__ == '__main__':
unittest.main()
diff --git a/reclass/utils/valuelist.py b/reclass/utils/valuelist.py
index 4e9e3d3..5e57f6f 100644
--- a/reclass/utils/valuelist.py
+++ b/reclass/utils/valuelist.py
@@ -4,6 +4,8 @@
# This file is part of reclass
#
+import copy
+
from reclass.utils.mergeoptions import MergeOptions
class ValueList(object):
@@ -65,6 +67,8 @@
for n, value in enumerate(self._values):
if n is 0:
output = self._values[0].render(context, options)
+ if isinstance(output, list):
+ output = copy.deepcopy(output)
else:
new = value.render(context, options)
if isinstance(output, dict) and isinstance(new, dict):