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:
|
try:
|
||||||
config.read(path)
|
config.read(path)
|
||||||
except (OSError, ConfigParser.ParsingError):
|
except (OSError, ConfigParser.ParsingError) as exc_msg:
|
||||||
msg = "The file '{}' is not in a valid INI format.".format(path)
|
msg = "The file '{}' is not in a valid INI format: {}".format(
|
||||||
|
path, exc_msg
|
||||||
|
)
|
||||||
ret = ReturnValue.INVALID_FORMAT
|
ret = ReturnValue.INVALID_FORMAT
|
||||||
return (ret, msg, value)
|
return (ret, msg, value)
|
||||||
|
|
||||||
|
@ -88,8 +88,11 @@ class TestValidationsReadIni(base.TestCase):
|
|||||||
tmpfile.close()
|
tmpfile.close()
|
||||||
|
|
||||||
self.assertEqual(validation.ReturnValue.INVALID_FORMAT, ret)
|
self.assertEqual(validation.ReturnValue.INVALID_FORMAT, ret)
|
||||||
self.assertEqual("The file '{}' is not in a valid INI format.".format(
|
asserted = ("The file '{path}' is not in a valid INI format: File "
|
||||||
tmp_name), msg)
|
"contains no section headers.\nfile: '{path}', line: 2\n"
|
||||||
|
"'[DEFAULT#\\n\'").format(path=tmp_name)
|
||||||
|
|
||||||
|
self.assertEqual(asserted, msg)
|
||||||
self.assertIsNone(value)
|
self.assertIsNone(value)
|
||||||
|
|
||||||
def test_get_result_key_not_found(self):
|
def test_get_result_key_not_found(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user