stefankoegl / python-json-pointer

Resolve JSON Pointers in Python
https://python-json-pointer.readthedocs.org/
Other
140 stars 43 forks source link

Optimizations from #16 reverted #21

Open stefankoegl opened 6 years ago

stefankoegl commented 6 years ago

I had to revert the optimizations from #16, because the tests of jsonpatch failed with

$ ./tests.py 
........E.......E...................................................................
======================================================================
ERROR: test_append (__main__.ApplyPatchTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests.py", line 218, in test_append
    {'op': 'add', 'path': '/foo/-', 'value': 4},
  File "/home/stefan/python-json-patch/jsonpatch.py", line 154, in apply_patch
    return patch.apply(doc, in_place)
  File "/home/stefan/python-json-patch/jsonpatch.py", line 364, in apply
    obj = operation.apply(obj)
  File "/home/stefan/python-json-patch/jsonpatch.py", line 438, in apply
    elif part > len(subobj) or part < 0:
TypeError: unorderable types: EndOfList() > int()

======================================================================
ERROR: test_js_file (__main__.ApplyPatchTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests.py", line 23, in test_js_file
    result = jsonpatch.apply_patch(test['doc'], test['patch'])
  File "/home/stefan/python-json-patch/jsonpatch.py", line 154, in apply_patch
    return patch.apply(doc, in_place)
  File "/home/stefan/python-json-patch/jsonpatch.py", line 364, in apply
    obj = operation.apply(obj)
  File "/home/stefan/python-json-patch/jsonpatch.py", line 438, in apply
    elif part > len(subobj) or part < 0:
TypeError: unorderable types: EndOfList() > int()

----------------------------------------------------------------------
Ran 84 tests in 0.019s

FAILED (errors=2)