Merge "ConfigParser exeption message should be returned"
This commit is contained in:
commit
328416ee61
validations_common
@ -60,8 +60,10 @@ def get_result(path, section, key, default=None):
|
||||
|
||||
try:
|
||||
config.read(path)
|
||||
except (OSError, ConfigParser.ParsingError):
|
||||
msg = "The file '{}' is not in a valid INI format.".format(path)
|
||||
except (OSError, ConfigParser.ParsingError) as exc_msg:
|
||||
msg = "The file '{}' is not in a valid INI format: {}".format(
|
||||
path, exc_msg
|
||||
)
|
||||
ret = ReturnValue.INVALID_FORMAT
|
||||
return (ret, msg, value)
|
||||
|
||||
|
@ -88,8 +88,11 @@ class TestValidationsReadIni(base.TestCase):
|
||||
tmpfile.close()
|
||||
|
||||
self.assertEqual(validation.ReturnValue.INVALID_FORMAT, ret)
|
||||
self.assertEqual("The file '{}' is not in a valid INI format.".format(
|
||||
tmp_name), msg)
|
||||
asserted = ("The file '{path}' is not in a valid INI format: File "
|
||||
"contains no section headers.\nfile: '{path}', line: 2\n"
|
||||
"'[DEFAULT#\\n\'").format(path=tmp_name)
|
||||
|
||||
self.assertEqual(asserted, msg)
|
||||
self.assertIsNone(value)
|
||||
|
||||
def test_get_result_key_not_found(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user