Sync yamlutils with solumclient changes for empty list
Change-Id: I27dfabe396ee7dc68a38d0c294c45c1f8696e5dc
This commit is contained in:
parent
5653efe454
commit
21b8fe01de
|
@ -34,9 +34,9 @@ def load(s):
|
|||
msg += ' Error position: (%s:%s)' % (exc.problem_mark.line + 1,
|
||||
exc.problem_mark.column + 1)
|
||||
raise ValueError(msg)
|
||||
if not isinstance(yml_dict, dict):
|
||||
raise ValueError('The source is not a YAML mapping.')
|
||||
if len(yml_dict) < 1:
|
||||
if not isinstance(yml_dict, dict) and not isinstance(yml_dict, list):
|
||||
raise ValueError('The source is not a YAML mapping or list.')
|
||||
if isinstance(yml_dict, dict) and len(yml_dict) < 1:
|
||||
raise ValueError('Could not find any element in your YAML mapping.')
|
||||
return yml_dict
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ class TestYamlUtils(base.BaseTestCase):
|
|||
def test_load_empty_yaml(self):
|
||||
self.assertRaises(ValueError, yamlutils.load, '{}')
|
||||
|
||||
def test_load_empty_list(self):
|
||||
yml_dict = yamlutils.load('[]')
|
||||
self.assertEqual(yml_dict, [])
|
||||
|
||||
def test_load_invalid_yaml_syntax(self):
|
||||
self.assertRaises(ValueError, yamlutils.load, "}invalid: y'm'l3!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue