Skip to content

Commit 1c643cb

Browse files
committed
fixing the issue with Using ignore_order and group_by simultaneously
1 parent 16e0421 commit 1c643cb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

deepdiff/diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def __init__(self,
231231
self.progress_logger = progress_logger
232232
self.cache_size = cache_size
233233
_parameters = self.__dict__.copy()
234+
_parameters['group_by'] = None # overwriting since these parameters will be passed on to other passes.
234235

235236
# Non-Root
236237
if _shared_parameters:

tests/test_ignore_order.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def test_cutoff_distance_for_pairs(self):
749749

750750
assert expected == diff_with_dist
751751

752-
def test_ignore_order_and_group_by(self):
752+
def test_ignore_order_and_group_by1(self):
753753
t1 = [
754754
{'id': 'AA', 'name': 'Joe', 'ate': ['Nothing']},
755755
{'id': 'BB', 'name': 'James', 'ate': ['Chips', 'Cheese']},
@@ -781,6 +781,13 @@ def test_ignore_order_and_group_by(self):
781781
expected2 = {'iterable_item_added': {"root['BB']['ate'][1]": 'Brownies'}}
782782
assert expected2 == diff2
783783

784+
def test_ignore_order_and_group_by2(self):
785+
t1_data = [{'id': '1', 'codes': ['1', '2', '3']}]
786+
t2_data = [{'id': '1', 'codes': ['1', '2', '4']}]
787+
diff = DeepDiff(t1_data, t2_data, group_by='id', ignore_order=True)
788+
expected = {'values_changed': {"root['1']['codes'][2]": {'new_value': '4', 'old_value': '3'}}}
789+
assert expected == diff
790+
784791

785792
class TestCompareFuncIgnoreOrder:
786793

0 commit comments

Comments
 (0)