Browse Source

Preserve order in list_concat_unique

Also, we should not modify a list when iterating
over it.

Task: 42359
Closes-Bug: #1925373
Change-Id: Iaa2c05b4155d93f44de60b6f98a69450c1512817
(cherry picked from commit a8f8528d1e)
changes/46/788146/1
ramishra 3 weeks ago
committed by Brendan Shephard
parent
commit
b9a3395978
2 changed files with 9 additions and 7 deletions
  1. +8
    -6
      heat/engine/hot/functions.py
  2. +1
    -1
      heat/tests/test_hot.py

+ 8
- 6
heat/engine/hot/functions.py View File

@ -1603,12 +1603,14 @@ class ListConcat(function.Function):
for m in args:
ret_list.extend(ensure_list(m))
if self._unique:
for i in ret_list:
while ret_list.count(i) > 1:
del ret_list[ret_list.index(i)]
return ret_list
if not self._unique:
return ret_list
unique_list = []
for item in ret_list:
if item not in unique_list:
unique_list.append(item)
return unique_list
class ListConcatUnique(ListConcat):


+ 1
- 1
heat/tests/test_hot.py View File

@ -2367,7 +2367,7 @@ resources:
self.assertEqual(snippet_resolved, resolved)
def test_list_concat_unique(self):
snippet = {'list_concat_unique': [['v1', 'v2'], ['v2', 'v3']]}
snippet = {'list_concat_unique': [['v1', 'v2'], ['v1', 'v3']]}
snippet_resolved = ['v1', 'v2', 'v3']
tmpl = template.Template(hot_pike_tpl_empty)
resolved = self.resolve(snippet, tmpl)


Loading…
Cancel
Save