You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test operation considers 1 and true (0 and false) equal #216
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:
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.
Fixed by 67c44eb ("Compare values in 'test' by JSON equality"), merged in #221.
On current master (077b4f4), testing 1 against true, 0 against false, [1] against [true] or {"a": 0} against {"a": false} raises JsonPatchTestFailed, while 1 against 1.0 still passes. test_test_operation_uses_json_equality in property_tests.py no longer carries expectedFailure and passes, at 5,000 examples on two hash seeds as well.
Activity
stefankoegl commentedon Oct 10, 2026
Fixed by 67c44eb ("Compare values in 'test' by JSON equality"), merged in #221.
On current master (077b4f4), testing
1againsttrue,0againstfalse,[1]against[true]or{"a": 0}against{"a": false}raisesJsonPatchTestFailed, while1against1.0still passes.test_test_operation_uses_json_equalityinproperty_tests.pyno longer carriesexpectedFailureand passes, at 5,000 examples on two hash seeds as well.Generated by Claude Code