From f2ab0c74986881e017199ac8a56dd09334a8b42b Mon Sep 17 00:00:00 2001 From: Eli Qiao Date: Thu, 19 Nov 2015 20:03:49 +0800 Subject: [PATCH] Improve yml template test case. Print out yml file name when failed to loading yml. Change-Id: Ie34282b91ec8101ffa2676e3144acf5a054578b0 --- magnum/tests/unit/template/test_template.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/magnum/tests/unit/template/test_template.py b/magnum/tests/unit/template/test_template.py index 3c2b5d09fa..546a5b9a24 100644 --- a/magnum/tests/unit/template/test_template.py +++ b/magnum/tests/unit/template/test_template.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. import os +import sys from glob import glob from oslo_config import cfg @@ -34,4 +35,8 @@ class TestTemplate(base.TestCase): for y in glob(os.path.join(x[0], '*.yaml'))]: with open(yml, 'r') as f: yml_contents = f.read() - load(yml_contents) + try: + load(yml_contents) + except Exception: + error_msg = "file: %s: %s" % (yml, sys.exc_info()[1]) + self.fail(error_msg)