Skip to content

deepdiff works wrong while comparing two list[dict] #344

@linkhao380

Description

@linkhao380

Describe the bug
When a list[dict] contains a duplicate object, deepdiff will works wrong.

To Reproduce

expect_value = [{"id": 1}, {"id": 1}, {"id": 1}]
actual_value = [{"id": 1, "name": 1}]
DeepDiff(
        expect_value,
        actual_value,
        view="tree",
        ignore_order=True,
        report_repetition=True,
        cutoff_intersection_for_pairs=1,
        cutoff_distance_for_pairs=1,
    )

Buggy Output = {'dictionary_item_added': [<root[0]['name'] t1:not present, t2:1>, <root[1]['name'] t1:not present, t2:1>, <root[2]['name'] t1:not present, t2:1>]}
Expected behavior
It is supposed to output contains 'iterable_item_removed' report_type.

Expected Output: {'dictionary_item_added': [<root[0]['name'] t1:not present, t2:1>], 'iterable_item_removed': [<root[1] t1:{'id': 1}, t2:not present>, <root[2] t1:{'id': 1}, t2:not present>]}

OS, DeepDiff version and Python version (please complete the following information):

  • OS: Windows
  • Version 10
  • Python Version 3.10.6
  • DeepDiff Version 5.8.1

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions