From 04596b810baf178ee3799c72c03bfe1990400418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 25 Nov 2017 19:13:39 +0100 Subject: [PATCH] Add test case for issue reported in #74 --- tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests.py b/tests.py index cdb805f..f238115 100755 --- a/tests.py +++ b/tests.py @@ -388,6 +388,17 @@ def test_arrays_one_element_sequences(self): res = jsonpatch.apply_patch(src, patch) self.assertEqual(res, dst) + def test_list_in_dict(self): + """ Test patch creation with a list within a dict, as reported in #74 + + https://github.com/stefankoegl/python-json-patch/issues/74 """ + old = {'key': [{'someNumber': 0, 'someArray': [1, 2, 3]}]} + new = {'key': [{'someNumber': 0, 'someArray': [1, 2, 3, 4]}]} + patch = jsonpatch.make_patch(old, new) + new_from_patch = jsonpatch.apply_patch(old, patch) + self.assertEqual(new, new_from_patch) + + class OptimizationTests(unittest.TestCase): def test_use_replace_instead_of_remove_add(self): src = {'foo': [1, 2, 3]}