Skip to content

Commit b740207

Browse files
committed
fix last failing test
1 parent 59e4239 commit b740207

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

jdiff/utils/diff_helpers.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ def fix_deepdiff_key_names(obj: Mapping) -> Dict:
6464
result = {} # type: Dict
6565
for key, value in obj.items():
6666
key_parts = re.findall(REGEX_PATTERN_RELEVANT_KEYS, key)
67-
if not key_parts: # If key parts can't be find, keep original key so data is not lost.
68-
key_parts = [key.replace("root", "index_element")] # replace root from DeepDiff with more meaningful name.
67+
if (
68+
not key_parts
69+
): # If key parts can't be find, keep original key so data is not lost.
70+
key_parts = [
71+
key.replace("root", "index_element")
72+
] # replace root from DeepDiff with more meaningful name.
6973
partial_res = group_value(key_parts, value)
7074
dict_merger(result, partial_res)
7175
return result
@@ -81,10 +85,16 @@ def group_value(tree_list: List, value: Dict) -> Dict:
8185
def dict_merger(original_dict: Dict, dict_to_merge: Dict):
8286
"""Function to merge a dictionary (dict_to_merge) recursively into the original_dict."""
8387
for key in dict_to_merge.keys():
84-
if key in original_dict and isinstance(original_dict[key], dict) and isinstance(dict_to_merge[key], dict):
88+
if (
89+
key in original_dict
90+
and isinstance(original_dict[key], dict)
91+
and isinstance(dict_to_merge[key], dict)
92+
):
8593
dict_merger(original_dict[key], dict_to_merge[key])
8694
elif key in original_dict.keys():
87-
original_dict[key + "_dup!"] = dict_to_merge[key] # avoid overwriting existing keys.
95+
original_dict[key + "_dup!"] = dict_to_merge[
96+
key
97+
] # avoid overwriting existing keys.
8898
else:
8999
original_dict[key] = dict_to_merge[key]
90100

@@ -122,30 +132,18 @@ def set_nested_value(data, keys, value):
122132
set_nested_value(data[keys[0]], keys[1:], value)
123133

124134

125-
def all_values_empty(input_dict):
126-
"""
127-
Checks if all values in a dictionary are empty objects (empty string, list, or dictionary).
128-
129-
Args:
130-
input_dict: The dictionary to check.
131-
132-
Returns:
133-
True if all values are empty, False otherwise.
134-
"""
135-
for value in input_dict.values():
136-
if value: # Empty objects evaluate to False in a boolean context
137-
return False
138-
return True
139-
140-
141135
def parse_diff(jdiff_evaluate_response, actual, intended, match_config):
142136
"""Parse jdiff evaluate result into missing and extra dictionaries."""
143137
extra = {}
144138
missing = {}
145139

146140
def process_diff(_map, extra_map, missing_map, previous_key=None):
147141
for key, value in _map.items():
148-
if isinstance(value, dict) and "new_value" in value and "old_value" in value:
142+
if (
143+
isinstance(value, dict)
144+
and "new_value" in value
145+
and "old_value" in value
146+
):
149147
extra_map[key] = value["old_value"]
150148
missing_map[key] = value["new_value"]
151149
elif isinstance(value, str):

0 commit comments

Comments
 (0)