RFC 6902 §4.6 compares numbers by value, but literals (true, false, null) are only equal to themselves. TestOperation compares with Python's !=, and in Python 1 == True and 0 == False. So these tests pass, although the values differ in JSON:
>>> import jsonpatch
>>> jsonpatch.apply_patch({'a': 1}, [{'op': 'test', 'path': '/a', 'value': True}])
{'a': 1}
>>> jsonpatch.apply_patch({'a': [1]}, [{'op': 'test', 'path': '/a', 'value': [True]}])
{'a': [1]}
>>> jsonpatch.apply_patch({'a': {'a': 0}}, [{'op': 'test', 'path': '/a', 'value': {'a': False}}])
{'a': {'a': 0}}
Expected: JsonPatchTestFailed. 1 against 1.0 should keep passing, since the RFC considers numerically equal numbers equal.
make_patch had the same problem (#180), fixed in #181 and 80086cd. test can't reuse _serialized_key unchanged, though: it compares json.dumps output, so it would also tell 1 and 1.0 apart. A recursive comparison would do: booleans only equal booleans, numbers compare by value, and arrays and objects compare member by member.
Related: JsonPatch.__eq__ also uses Python equality. It considers [{'op': 'test', 'path': '/a', 'value': 1}] and the same patch with True equal, although the two behave differently.
Test: OperationProperties.test_test_operation_uses_json_equality in property_tests.py is marked @unittest.expectedFailure because of this bug.
RFC 6902 §4.6 compares numbers by value, but literals (
true,false,null) are only equal to themselves.TestOperationcompares with Python's!=, and in Python1 == Trueand0 == False. So these tests pass, although the values differ in JSON:Expected:
JsonPatchTestFailed.1against1.0should keep passing, since the RFC considers numerically equal numbers equal.make_patchhad the same problem (#180), fixed in #181 and 80086cd.testcan't reuse_serialized_keyunchanged, though: it comparesjson.dumpsoutput, so it would also tell1and1.0apart. A recursive comparison would do: booleans only equal booleans, numbers compare by value, and arrays and objects compare member by member.Related:
JsonPatch.__eq__also uses Python equality. It considers[{'op': 'test', 'path': '/a', 'value': 1}]and the same patch withTrueequal, although the two behave differently.Test:
OperationProperties.test_test_operation_uses_json_equalityinproperty_tests.pyis marked@unittest.expectedFailurebecause of this bug.