summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/models/base_models.py
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2018-01-04 08:59:41 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-01-04 08:59:41 +0000
commit8dbe224064851d439b18ad4254e119aff7f02e30 (patch)
tree939ff74837fe2593b532a455c65b06edba6ec957 /testapi/opnfv_testapi/models/base_models.py
parent6d98b992423084dd737e80322c9360e0712368a2 (diff)
parent8dd0bcd2e98d283619d12c9734c126b19757f065 (diff)
Merge "simplify test_pod.py with eq"
Diffstat (limited to 'testapi/opnfv_testapi/models/base_models.py')
-rw-r--r--testapi/opnfv_testapi/models/base_models.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/testapi/opnfv_testapi/models/base_models.py b/testapi/opnfv_testapi/models/base_models.py
index 5017e85..efce0ad 100644
--- a/testapi/opnfv_testapi/models/base_models.py
+++ b/testapi/opnfv_testapi/models/base_models.py
@@ -42,15 +42,16 @@ class ModelBase(object):
attr_parser = cls.attr_parser()
t = cls()
for k, v in a_dict.iteritems():
- value = v
- if isinstance(v, dict) and k in attr_parser:
- value = attr_parser[k].from_dict(v)
- elif isinstance(v, list) and k in attr_parser:
- value = []
- for item in v:
- value.append(attr_parser[k].from_dict(item))
-
- t.__setattr__(k, value)
+ if k in t.__dict__:
+ value = v
+ if isinstance(v, dict) and k in attr_parser:
+ value = attr_parser[k].from_dict(v)
+ elif isinstance(v, list) and k in attr_parser:
+ value = []
+ for item in v:
+ value.append(attr_parser[k].from_dict(item))
+
+ t.__setattr__(k, value)
return t