Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepdiff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def _get_clean_to_keys_mapping(self, keys, level):
clean_key = KEY_TO_VAL_STR.format(type_, clean_key)
else:
clean_key = key
if self.ignore_string_case:
if self.ignore_string_case and isinstance(clean_key, str):
clean_key = clean_key.lower()
if clean_key in result:
logger.warning(('{} and {} in {} become the same key when ignore_numeric_type_changes'
Expand Down
22 changes: 22 additions & 0 deletions tests/test_diff_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,3 +2147,25 @@ class MyDataClass:

diff = DeepDiff(t1, t2, exclude_regex_paths=["any"])
assert {'values_changed': {'root[MyDataClass(val=2,val2=4)]': {'new_value': 10, 'old_value': 20}}} == diff


def test_group_by_with_none_key_and_ignore_case(self):
"""Test that group_by works with None keys when ignore_string_case is True"""
dict1 = [{'txt_field': 'FULL_NONE', 'group_id': None}, {'txt_field': 'FULL', 'group_id': 'a'}]
dict2 = [{'txt_field': 'PARTIAL_NONE', 'group_id': None}, {'txt_field': 'PARTIAL', 'group_id': 'a'}]

diff = DeepDiff(
dict1,
dict2,
ignore_order=True,
group_by='group_id',
ignore_string_case=True
)

expected = {'values_changed': {"root[None]['txt_field']":
{'new_value': 'partial_none', 'old_value': 'full_none'},
"root['a']['txt_field']":
{'new_value': 'partial', 'old_value': 'full'}
}
}
assert expected == diff
Loading