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
This commit is contained in:
parent
49e5e12059
commit
a8f8528d1e
@ -1643,12 +1643,14 @@ class ListConcat(function.Function):
|
|||||||
for m in args:
|
for m in args:
|
||||||
ret_list.extend(ensure_list(m))
|
ret_list.extend(ensure_list(m))
|
||||||
|
|
||||||
if self._unique:
|
if not self._unique:
|
||||||
for i in ret_list:
|
return ret_list
|
||||||
while ret_list.count(i) > 1:
|
|
||||||
del ret_list[ret_list.index(i)]
|
|
||||||
|
|
||||||
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):
|
class ListConcatUnique(ListConcat):
|
||||||
|
@ -2399,7 +2399,7 @@ resources:
|
|||||||
self.assertEqual(snippet_resolved, resolved)
|
self.assertEqual(snippet_resolved, resolved)
|
||||||
|
|
||||||
def test_list_concat_unique(self):
|
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']
|
snippet_resolved = ['v1', 'v2', 'v3']
|
||||||
tmpl = template.Template(hot_pike_tpl_empty)
|
tmpl = template.Template(hot_pike_tpl_empty)
|
||||||
resolved = self.resolve(snippet, tmpl)
|
resolved = self.resolve(snippet, tmpl)
|
||||||
|
Loading…
Reference in New Issue
Block a user