Skip to content

Commit 85adbd2

Browse files
author
Mate Valko
committed
add tests for group_by None cases
1 parent f6c7bcb commit 85adbd2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_diff_text.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,3 +2147,25 @@ class MyDataClass:
21472147

21482148
diff = DeepDiff(t1, t2, exclude_regex_paths=["any"])
21492149
assert {'values_changed': {'root[MyDataClass(val=2,val2=4)]': {'new_value': 10, 'old_value': 20}}} == diff
2150+
2151+
2152+
def test_group_by_with_none_key_and_ignore_case(self):
2153+
"""Test that group_by works with None keys when ignore_string_case is True"""
2154+
dict1 = [{'txt_field': 'FULL_NONE', 'group_id': None}, {'txt_field': 'FULL', 'group_id': 'a'}]
2155+
dict2 = [{'txt_field': 'PARTIAL_NONE', 'group_id': None}, {'txt_field': 'PARTIAL', 'group_id': 'a'}]
2156+
2157+
diff = DeepDiff(
2158+
dict1,
2159+
dict2,
2160+
ignore_order=True,
2161+
group_by='group_id',
2162+
ignore_string_case=True
2163+
)
2164+
2165+
expected = {'values_changed': {"root[None]['txt_field']":
2166+
{'new_value': 'partial_none', 'old_value': 'full_none'},
2167+
"root['a']['txt_field']":
2168+
{'new_value': 'partial', 'old_value': 'full'}
2169+
}
2170+
}
2171+
assert expected == diff

0 commit comments

Comments
 (0)