Skip to content

Commit ae895f7

Browse files
committed
Add test case for issue reported in #41
1 parent 04596b8 commit ae895f7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ def test_list_in_dict(self):
398398
new_from_patch = jsonpatch.apply_patch(old, patch)
399399
self.assertEqual(new, new_from_patch)
400400

401+
def test_nested(self):
402+
""" Patch creation with nested dicts, as reported in #41
403+
404+
https://github.com/stefankoegl/python-json-patch/issues/41 """
405+
old = {'school':{'names':['Kevin','Carl']}}
406+
new = {'school':{'names':['Carl','Kate','Kevin','Jake']}}
407+
patch = jsonpatch.JsonPatch.from_diff(old, new)
408+
new_from_patch = jsonpatch.apply_patch(old, patch)
409+
self.assertEqual(new, new_from_patch)
410+
401411

402412
class OptimizationTests(unittest.TestCase):
403413
def test_use_replace_instead_of_remove_add(self):

0 commit comments

Comments
 (0)