@@ -840,13 +840,15 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
840
840
if self ._count_diff () is StopIteration :
841
841
return # pragma: no cover. This is already covered for addition.
842
842
843
+ reference_param1 = i
844
+ reference_param2 = j
843
845
if y is ListItemRemovedOrAdded : # item removed completely
844
846
change_level = level .branch_deeper (
845
847
x ,
846
848
notpresent ,
847
849
child_relationship_class = child_relationship_class ,
848
- child_relationship_param = i ,
849
- child_relationship_param2 = j ,
850
+ child_relationship_param = reference_param1 ,
851
+ child_relationship_param2 = reference_param2 ,
850
852
)
851
853
self ._report_result ('iterable_item_removed' , change_level , local_tree = local_tree )
852
854
@@ -855,8 +857,8 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
855
857
notpresent ,
856
858
y ,
857
859
child_relationship_class = child_relationship_class ,
858
- child_relationship_param = i ,
859
- child_relationship_param2 = j ,
860
+ child_relationship_param = reference_param1 ,
861
+ child_relationship_param2 = reference_param2 ,
860
862
)
861
863
self ._report_result ('iterable_item_added' , change_level , local_tree = local_tree )
862
864
@@ -868,26 +870,30 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
868
870
x ,
869
871
y ,
870
872
child_relationship_class = child_relationship_class ,
871
- child_relationship_param = i ,
872
- child_relationship_param2 = j
873
+ child_relationship_param = reference_param1 ,
874
+ child_relationship_param2 = reference_param2
873
875
)
874
876
self ._report_result ('iterable_item_moved' , change_level , local_tree = local_tree )
875
877
878
+ if self .iterable_compare_func :
879
+ # Intentionally setting j as the first child relationship param in cases of a moved item.
880
+ # If the item was moved using an iterable_compare_func then we want to make sure that the index
881
+ # is relative to t2.
882
+ reference_param1 = j
883
+ reference_param2 = i
884
+
876
885
item_id = id (x )
877
886
if parents_ids and item_id in parents_ids :
878
887
continue
879
888
parents_ids_added = add_to_frozen_set (parents_ids , item_id )
880
889
881
890
# Go one level deeper
882
- # Intentionally setting j as the first child relationship param in cases of a moved item.
883
- # If the item was moved using an iterable_compare_func then we want to make sure that the index
884
- # is relative to t2.
885
891
next_level = level .branch_deeper (
886
892
x ,
887
893
y ,
888
894
child_relationship_class = child_relationship_class ,
889
- child_relationship_param = j ,
890
- child_relationship_param2 = i
895
+ child_relationship_param = reference_param1 ,
896
+ child_relationship_param2 = reference_param2
891
897
)
892
898
self ._diff (next_level , parents_ids_added , local_tree = local_tree )
893
899
0 commit comments