Merge "Fix parsing bug when config file is empty."
This commit is contained in:
commit
f62fd2b499
@ -350,7 +350,7 @@ def parse_file_contents(data):
|
||||
# For backwards-compatibility, convert yaml error to ValueError,
|
||||
# which is what JSON loader raised.
|
||||
raise ValueError(six.text_type(e))
|
||||
return parsed
|
||||
return parsed or {}
|
||||
|
||||
|
||||
class Rules(dict):
|
||||
|
@ -129,6 +129,11 @@ class RulesTestCase(test_base.BaseTestCase):
|
||||
self.assertRaises(ValueError, policy.Rules.load, exemplar,
|
||||
'default')
|
||||
|
||||
@mock.patch.object(_parser, 'parse_rule', lambda x: x)
|
||||
def test_load_empty_data(self):
|
||||
result = policy.Rules.load('', 'default')
|
||||
self.assertEqual(result, {})
|
||||
|
||||
@mock.patch.object(_parser, 'parse_rule', lambda x: x)
|
||||
def test_load_yaml(self):
|
||||
# Test that simplified YAML can be used with load().
|
||||
|
Loading…
x
Reference in New Issue
Block a user