Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions patchdiff/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@


def to_str_paths(ops: List) -> List:
str_ops = ops.copy()
for op in str_ops:
op["path"] = str(op["path"])
return str_ops
return [{**op, "path": str(op["path"])} for op in ops]


def to_json(ops: List, **kwargs) -> str:
Expand Down
12 changes: 11 additions & 1 deletion tests/test_serialize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from patchdiff import diff, to_json
from patchdiff import apply, diff, to_json


def test_to_json_does_not_mutate_ops():
a = {"x": [1, 2, 3]}
b = {"x": [1, 9, 3]}
ops, _ = diff(a, b)

to_json(ops)

assert apply(a, ops) == b


def test_to_json():
Expand Down
Loading