Fix deprecated yaml loader usage

Using `yaml.load()` without a loader is deprecated. This update replaces
this method with `yaml.safe_load()` uses `yaml.SafeLoader`.

Change-Id: I69caca2775d43de59e10c04a7684b22d999beab6
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
This commit is contained in:
Yasufumi Ogawa 2020-08-11 04:38:39 +00:00
parent 9b42fa3d32
commit d377abc6b2
2 changed files with 7 additions and 7 deletions

View File

@ -141,7 +141,7 @@ class CSAR(object):
'contain valid TOSCA YAML content.') %
{'template': main_template, 'csar': self.path})
try:
tosca_yaml = yaml.load(data)
tosca_yaml = yaml.safe_load(data)
if type(tosca_yaml) is not dict:
ExceptionCollector.appendException(
ValidationError(message=invalid_tosca_yaml_err_msg))
@ -289,7 +289,7 @@ class CSAR(object):
'contain valid YAML content.') %
{'template': template, 'csar': self.path})
try:
tosca_yaml = yaml.load(data)
tosca_yaml = yaml.safe_load(data)
if type(tosca_yaml) is not dict:
ExceptionCollector.appendException(
ValidationError(message=invalid_tosca_yaml_err_msg))

View File

@ -110,7 +110,7 @@ class ConstraintTest(TestCase):
def test_invalid_in_range(self):
snippet = 'in_range: {2, 6}'
schema = yaml.load(snippet)
schema = yaml.safe_load(snippet)
error = self.assertRaises(exception.InvalidSchemaError, Constraint,
'prop', Schema.INTEGER,
schema)
@ -171,7 +171,7 @@ class ConstraintTest(TestCase):
def test_greater_than_invalid(self):
snippet = 'greater_than: {4}'
schema = yaml.load(snippet)
schema = yaml.safe_load(snippet)
error = self.assertRaises(exception.InvalidSchemaError, Constraint,
'prop', Schema.INTEGER,
schema)
@ -201,7 +201,7 @@ class ConstraintTest(TestCase):
def test_greater_or_equal_invalid(self):
snippet = 'greater_or_equal: {3.9}'
schema = yaml.load(snippet)
schema = yaml.safe_load(snippet)
error = self.assertRaises(exception.InvalidSchemaError, Constraint,
'prop', Schema.INTEGER,
schema)
@ -233,7 +233,7 @@ class ConstraintTest(TestCase):
def test_less_than_invalid(self):
snippet = 'less_than: {3.9}'
schema = yaml.load(snippet)
schema = yaml.safe_load(snippet)
error = self.assertRaises(exception.InvalidSchemaError, Constraint,
'prop', Schema.INTEGER,
schema)
@ -256,7 +256,7 @@ class ConstraintTest(TestCase):
def test_less_or_equal_invalid(self):
snippet = 'less_or_equal: {3.9}'
schema = yaml.load(snippet)
schema = yaml.safe_load(snippet)
error = self.assertRaises(exception.InvalidSchemaError, Constraint,
'prop', Schema.INTEGER,
schema)