Merge "Scenario is reporting result for last test only"
[yardstick.git] / yardstick / common / template_format.py
index 881b7e4..e1662ce 100644 (file)
 
 # yardstick: this file is copied from python-heatclient and slightly modified
 
-import json
+from __future__ import absolute_import
+
 import yaml
+from oslo_serialization import jsonutils
 
 if hasattr(yaml, 'CSafeLoader'):
     yaml_loader = yaml.CSafeLoader
@@ -40,13 +42,13 @@ yaml_loader.add_constructor(u'tag:yaml.org,2002:timestamp',
 
 
 def parse(tmpl_str):
-    '''Takes a string and returns a dict containing the parsed structure.
+    """Takes a string and returns a dict containing the parsed structure.
 
     This includes determination of whether the string is using the
     JSON or YAML format.
-    '''
+    """
     if tmpl_str.startswith('{'):
-        tpl = json.loads(tmpl_str)
+        tpl = jsonutils.loads(tmpl_str)
     else:
         try:
             tpl = yaml.load(tmpl_str, Loader=yaml_loader)
@@ -56,8 +58,8 @@ def parse(tmpl_str):
             if tpl is None:
                 tpl = {}
     # Looking for supported version keys in the loaded template
-    if not ('HeatTemplateFormatVersion' in tpl
-            or 'heat_template_version' in tpl
-            or 'AWSTemplateFormatVersion' in tpl):
+    if not ('HeatTemplateFormatVersion' in tpl or
+            'heat_template_version' in tpl or
+            'AWSTemplateFormatVersion' in tpl):
         raise ValueError("Template format version not found.")
     return tpl