Ensure we don't pass empty params
When using automated generation for some of the params we get an empty line entry at some point, leading to an empty parameter being added to the command. The unit-test was updated accordingly in order to avoid regressions. Change-Id: I82c9e68bea1a206c001f71873c213c0242380345
This commit is contained in:
parent
0ab073c09b
commit
3bda80918d
|
@ -34,9 +34,10 @@ class FilterModule(object):
|
|||
arg = [arg]
|
||||
return_value = []
|
||||
for a in arg:
|
||||
val = quote(a)
|
||||
if parameter:
|
||||
return_value.append("{} {}".format(parameter, val))
|
||||
else:
|
||||
return_value.append(val)
|
||||
if a:
|
||||
val = quote(a)
|
||||
if parameter:
|
||||
return_value.append("{} {}".format(parameter, val))
|
||||
else:
|
||||
return_value.append(val)
|
||||
return ' '.join(return_value)
|
||||
|
|
|
@ -53,3 +53,9 @@ class TestShellArgsFilters(tests_base.TestCase):
|
|||
expected = "'a b'"
|
||||
self.assertEqual(expected,
|
||||
self.filter.shell_arg_list(arg))
|
||||
|
||||
def test_shell_arg_list_avoid_none_in_list(self):
|
||||
arg = ['a', None]
|
||||
expected = '-p a'
|
||||
self.assertEqual(expected,
|
||||
self.filter.shell_arg_list(arg, parameter='-p'))
|
||||
|
|
Loading…
Reference in New Issue