Repository navigation
Commit 268f0a3
committed
Add property-based tests using Hypothesis
property_tests.py checks general properties of jsonpatch against generated
documents and patches:
- make_patch: diffing equal documents gives an empty patch, applying
make_patch(src, dst) to src gives dst, inputs are not modified, the
result shares no objects with dst
- apply_patch: the document and the patch are not modified, only
JsonPatchException / JsonPointerException are raised (also for
malformed patches), in_place and string patches give the same result
- single operations: whole-document targets and sources, moving into
own children, replace of any existing location, 'test' using JSON
equality
- JsonPatch: string roundtrip, equal patches have equal hashes
- a state machine applying random valid operations and comparing each
result with a direct implementation of RFC 6902
Properties that do not hold yet are expected failures, each pinned to the
minimal counterexample Hypothesis found. Among them are known issues
(#124, #137, #138, #179, #180, #190) and some that appear to be
unreported: make_patch mishandling object keys that int() accepts,
replace rejecting the object member '-', hash() failing for patches with
array/object values, 'test' treating 1 and true as equal, copy from the
whole document failing, and moves into own children being allowed for
array members.
The tests run in CI and via "make test".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqGXptMsaz9bfrMoaMpZ1A1 parent 4f39f79 commit 268f0a3
6 files changed
Lines changed: 618 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments