File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -526,6 +526,16 @@ def test_issue119(self):
526526 res = jsonpatch .apply_patch (src , patch )
527527 self .assertEqual (res , dst )
528528
529+ def test_numeric_string_dict_keys (self ):
530+ """Test the reported issue with numeric string dict keys"""
531+ src = {'1' : 'def' }
532+ dst = {'test' : '1' , 'b' : 'def' }
533+ # This should not raise an exception
534+ patch = jsonpatch .make_patch (src , dst )
535+ # Verify the patch works as expected
536+ res = jsonpatch .apply_patch (src , patch )
537+ self .assertEqual (res , dst )
538+
529539 def test_issue120 (self ):
530540 """Make sure it avoids casting numeric str dict key to int"""
531541 src = [{'foobar' : {'821b7213_b9e6_2b73_2e9c_cf1526314553' : ['Open Work' ],
Original file line number Diff line number Diff line change 1+ import unittest
2+ import jsonpatch
3+
4+ class IssueBugTestCase (unittest .TestCase ):
5+ def test_numeric_string_dict_keys (self ):
6+ """Test the issue with numeric string dict keys"""
7+ src = {'1' : 'def' }
8+ dst = {'test' : '1' , 'b' : 'def' }
9+ # This should not raise an exception
10+ patch = jsonpatch .make_patch (src , dst )
11+ # Verify the patch works as expected
12+ applied = jsonpatch .apply_patch (src , patch )
13+ self .assertEqual (applied , dst )
14+
15+ if __name__ == '__main__' :
16+ unittest .main ()
You can’t perform that action at this time.
0 commit comments