diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-23 15:31:14 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-23 15:36:43 +0800 |
commit | 53ed9e36a13d03455fc04b3f54ed290037359f6b (patch) | |
tree | a962991cf77c17566c4a808e503835c47fcc2ee5 /utils/test/testapi/opnfv_testapi/resources | |
parent | 59f96c0b4fb704339bf45c8af943070f6adcf7b9 (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 'utils/test/testapi/opnfv_testapi/resources')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/resources/models.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/models.py b/utils/test/testapi/opnfv_testapi/resources/models.py index c85c1d5b1..a281c66d8 100644 --- a/utils/test/testapi/opnfv_testapi/resources/models.py +++ b/utils/test/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])
|