Merge "Fix str_split function when string is None"
This commit is contained in:
commit
36dd261a97
@ -765,6 +765,10 @@ class StrSplit(function.Function):
|
||||
except (AttributeError, IndexError):
|
||||
raise ValueError(_('Incorrect arguments to "%(fn_name)s" '
|
||||
'should be: %(example)s') % self.fmt_data)
|
||||
|
||||
if str_to_split is None:
|
||||
return None
|
||||
|
||||
split_list = str_to_split.split(delim)
|
||||
|
||||
# Optionally allow an index to be specified
|
||||
|
@ -1291,6 +1291,16 @@ class HOTemplateTest(common.HeatTestCase):
|
||||
self.assertIn('Incorrect arguments to \"str_split\"',
|
||||
six.text_type(exc))
|
||||
|
||||
def test_str_split_none_string_to_split(self):
|
||||
tmpl = template.Template(hot_liberty_tpl_empty)
|
||||
snippet = {'str_split': ['.', None]}
|
||||
self.assertIsNone(self.resolve(snippet, tmpl))
|
||||
|
||||
def test_str_split_none_delim(self):
|
||||
tmpl = template.Template(hot_liberty_tpl_empty)
|
||||
snippet = {'str_split': [None, 'check']}
|
||||
self.assertEqual(['check'], self.resolve(snippet, tmpl))
|
||||
|
||||
def test_prevent_parameters_access(self):
|
||||
"""Check parameters section inaccessible using the template as a dict.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user