mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-23 17:42:22 +00:00
Merge pull request #6443 from GalaxyGorilla/json_diff_fix
tests: Fix JSON diff for nested lists
This commit is contained in:
commit
49a3882df1
@ -463,5 +463,39 @@ def test_json_object_asterisk_matching():
|
||||
assert json_cmp(dcomplete, dsub4) is None
|
||||
|
||||
|
||||
def test_json_list_nested_with_objects():
|
||||
|
||||
dcomplete = [
|
||||
{
|
||||
"key": 1,
|
||||
"list": [
|
||||
123
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": 2,
|
||||
"list": [
|
||||
123
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
dsub1 = [
|
||||
{
|
||||
"key": 2,
|
||||
"list": [
|
||||
123
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": 1,
|
||||
"list": [
|
||||
123
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
assert json_cmp(dcomplete, dsub1) is None
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main())
|
||||
|
@ -173,7 +173,9 @@ def gen_json_diff_report(d1, d2, exact=False, path="> $", acc=(0, "")):
|
||||
closest_diff = None
|
||||
closest_idx = None
|
||||
for idx1, v1 in zip(range(0, len(d1)), d1):
|
||||
tmp_diff = gen_json_diff_report(v1, v2, path=add_idx(idx1))
|
||||
tmp_v1 = deepcopy(v1)
|
||||
tmp_v2 = deepcopy(v2)
|
||||
tmp_diff = gen_json_diff_report(tmp_v1, tmp_v2, path=add_idx(idx1))
|
||||
if not has_errors(tmp_diff):
|
||||
found_match = True
|
||||
del d1[idx1]
|
||||
|
Loading…
Reference in New Issue
Block a user