From 3b9d9e7d03186f8925548b0ce6db5d80e2dfcb8f Mon Sep 17 00:00:00 2001 From: Moshe Date: Thu, 4 Apr 2019 11:56:48 +0300 Subject: fix s-overflow caused by cyclic reference Issue-ID: VNFSDK-350 Change-Id: I23c53a7e614841abc54d7e35ddf97cfffaa23a4a Signed-off-by: Moshe fix test Issue-ID: VNFSDK-350 Change-Id: I5b3e67c2a595ef9048d6e6fc7181ae3f0248c8d4 Signed-off-by: Moshe coverage report Issue-ID: VNFSDK-350 Change-Id: I685ba57fd23df551c747efeecd2061fabe825535 Signed-off-by: Moshe --- coverage.xml | 1288 ++++++++++++++++++++++++----------------------- vnftest/common/utils.py | 20 +- 2 files changed, 667 insertions(+), 641 deletions(-) diff --git a/coverage.xml b/coverage.xml index 250900c..1542bad 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -525,7 +525,7 @@ - + @@ -1101,7 +1101,7 @@ - + @@ -1368,74 +1368,74 @@ - - + + - + - + - - - + + + - - - + + + + + - - - - - - + + + + - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + - + - - - - - - - + + + + + + + - - - - + + - - - - - - + + + + + + @@ -1443,24 +1443,30 @@ - - + + + - - - + + + + - - - - - - - + + + + + + - + + + + + + @@ -1480,7 +1486,7 @@ - + @@ -1573,24 +1579,21 @@ - - - + + + - + - - - + - @@ -1601,18 +1604,18 @@ + - + + - - - - + + + + - - - - + + @@ -1635,322 +1638,325 @@ - - - - - - - - - - + + + + + + + + + + + - + - - - + + + - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - + - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + - - - - - - + + + + + + + + - - + - - + + - - + + - + - - - + + + - - - - - - - - + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + + - - + - + - + + - - - - - - - - - - + + + + + + + + + + - + - + + - - - - - + + + - - - - - + + + + + + - - + + - - - - - - - - - + + + + + + + + + + - + - - - + - + + + - - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + - + - - - - - + + + + + - + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + @@ -1964,58 +1970,59 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + - - - + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + - + @@ -2194,7 +2201,7 @@ - + @@ -2214,7 +2221,7 @@ - + @@ -2228,129 +2235,142 @@ - + - - - - - - - - - - - - - + + + + + + + + - - - + + + + - + - - - - - - + + + + + - - + + + - - + + - - - + + + - + - - - - + + + - - - + + + + - + - + - - - - - - - + + + + + + + - - - + + + - - - + + + + + - - + + - - - - - - - + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -2832,8 +2852,7 @@ - - + @@ -2843,233 +2862,234 @@ - + - + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - - - - - + + + + + + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + + - - + + + diff --git a/vnftest/common/utils.py b/vnftest/common/utils.py index b3f0c05..81dc8d7 100644 --- a/vnftest/common/utils.py +++ b/vnftest/common/utils.py @@ -420,26 +420,32 @@ def deep_dotdict(obj): return obj -def normalize_data_struct(obj): +def normalize_data_struct(obj, cache={}): if obj is None: return None + if id(obj) in cache.keys(): + return cache[id(obj)] if isinstance(obj, list): - nomalized_list = [] + normalized_list = [] for element in obj: - element = normalize_data_struct(element) - nomalized_list.append(element) - return nomalized_list + element = normalize_data_struct(element, cache) + normalized_list.append(element) + return normalized_list if isinstance(obj, dict): normalized_dict = {} for k, v in obj.items(): if isinstance(k, basestring) and not k.startswith('_'): - v = normalize_data_struct(v) + v = normalize_data_struct(v, cache) normalized_dict[k] = v return normalized_dict # return obj if it is string, integer, bool ect. if not hasattr(obj, '__dict__'): return obj - return normalize_data_struct(obj.__dict__) + obj_as_dict = {} + cache[id(obj)] = obj_as_dict + normalized = normalize_data_struct(obj.__dict__, cache) + obj_as_dict.update(normalized) + return obj_as_dict def xml_to_dict(xml_str): -- cgit 1.2.3-korg