Skip to content

Commit

Permalink
add tests for group_by None cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Mate Valko committed Dec 7, 2024
1 parent f6c7bcb commit 85adbd2
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit 85adbd2

Please sign in to comment.