mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 20:09:11 +00:00
Fixing merge_lists to work for list_or_* types
This commit is contained in:
parent
29aa81a694
commit
ead0be2763
@ -20,7 +20,7 @@ from unittest import TestCase
|
||||
from nose.tools import raises, assert_equal, assert_not_equal # pylint: disable=E0611
|
||||
|
||||
from wlauto.utils.android import check_output
|
||||
from wlauto.utils.misc import merge_dicts, TimeoutError
|
||||
from wlauto.utils.misc import merge_dicts, merge_lists, TimeoutError
|
||||
from wlauto.utils.types import list_or_integer, list_or_bool, caseless_string, arguments
|
||||
|
||||
|
||||
@ -56,6 +56,12 @@ class TestMerge(TestCase):
|
||||
result = merge_dicts(base, other, list_duplicates='last')
|
||||
assert_equal(result['a'], [1, 2, 3, 4, 5])
|
||||
|
||||
def test_merge_lists(self):
|
||||
result = merge_lists([1, 2, 3], 7)
|
||||
assert_equal(result, [1, 2, 3, 7])
|
||||
result = merge_lists([1, 2, 3], 1, duplicates='last')
|
||||
assert_equal(result, [2, 3, 1])
|
||||
|
||||
@raises(ValueError)
|
||||
def test_type_mismatch(self):
|
||||
base = {'a': [1, 2, 3]}
|
||||
|
@ -330,6 +330,10 @@ def _merge_two_lists(base, other, duplicates='all', dict_type=dict): # pylint:
|
||||
will never be removed.
|
||||
|
||||
"""
|
||||
if not isiterable(base):
|
||||
base = [base]
|
||||
if not isiterable(other):
|
||||
other = [other]
|
||||
if duplicates == 'all':
|
||||
merged_list = []
|
||||
for v in normalize(base, dict_type) + normalize(other, dict_type):
|
||||
|
Loading…
x
Reference in New Issue
Block a user