summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/resources
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-23 15:31:14 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-23 15:36:43 +0800
commit0d6df87202f4039ffff5e23957103cc1c8ca732a (patch)
tree6fb4e41c2b8957354b466583c8d71267b8722526 /testapi/opnfv_testapi/resources
parent34965c8cd55ad834693b4c53ce1e8fc9b99b3c4a (diff)
bugfix: access results failed of Test API
File "/Users/fengxiaowei/opnfv/releng/utils/test/testapi/venv/lib/python2.7/site-packages/opnfv_testapi/resources/models.py", line 47, in format_http return self._format([]) File "/Users/fengxiaowei/opnfv/releng/utils/test/testapi/venv/lib/python2.7/site-packages/opnfv_testapi/resources/models.py", line 37, in _format hs.append(h.format()) AttributeError: 'dict' object has no attribute 'format' JIRA: FUNCTEST-676 Change-Id: I9d8d8a31e5580be51fb690628a03d452742f12d4 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/resources')
-rw-r--r--testapi/opnfv_testapi/resources/models.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/testapi/opnfv_testapi/resources/models.py b/testapi/opnfv_testapi/resources/models.py
index c85c1d5..a281c66 100644
--- a/testapi/opnfv_testapi/resources/models.py
+++ b/testapi/opnfv_testapi/resources/models.py
@@ -24,7 +24,6 @@ class ModelBase(object):
def _format(self, excludes):
new_obj = copy.deepcopy(self)
dicts = new_obj.__dict__
- print self, self.__class__
for k in dicts.keys():
if k in excludes:
del dicts[k]
@@ -32,9 +31,9 @@ class ModelBase(object):
if hasattr(dicts[k], 'format'):
dicts[k] = dicts[k].format()
elif isinstance(dicts[k], list):
- hs = []
- for h in dicts[k]:
- hs.append(h.format())
+ hs = list()
+ [hs.append(h.format() if hasattr(h, 'format') else str(h))
+ for h in dicts[k]]
dicts[k] = hs
elif not isinstance(dicts[k], (str, int, float, dict)):
dicts[k] = str(dicts[k])