Skip to content

Commit b7017a8

Browse files
Copilotstefankoegl
andcommitted
Initial analysis of the issue
Co-authored-by: stefankoegl <[email protected]>
1 parent 5d72dc2 commit b7017a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,18 @@ def test_move_from_numeric_to_alpha_dict_key(self):
483483
patch = jsonpatch.make_patch(src, dst)
484484
res = jsonpatch.apply_patch(src, patch)
485485
self.assertEqual(res, dst)
486+
487+
def test_list_of_lists_add(self):
488+
"""Test patch when inserting an element into a list of lists."""
489+
a = [[1,'a']]
490+
b = [[2,'b'], [1,'a']]
491+
patch = jsonpatch.make_patch(a, b)
492+
self.assertEqual(len(patch.patch), 1)
493+
self.assertEqual(patch.patch[0]['op'], 'add')
494+
self.assertEqual(patch.patch[0]['path'], '/0')
495+
self.assertEqual(patch.patch[0]['value'], [2, 'b'])
496+
res = jsonpatch.apply_patch(a, patch)
497+
self.assertEqual(res, b)
486498

487499
def test_issue90(self):
488500
"""In JSON 1 is different from True even though in python 1 == True"""

0 commit comments

Comments
 (0)