-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility for stripping DiffEntry class from diff objects, left wit…
…h only pure python dict objects without attribute access, and test conversion to/from json with this.
- Loading branch information
Martin Sandve Alnæs
committed
Jan 29, 2016
1 parent
7505bcd
commit 003da65
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import json | ||
from nbdime import diff | ||
from nbdime.diff_format import to_clean_dicts | ||
|
||
def test_diff_to_json(): | ||
a = { "foo": [1,2,3], "bar": {"ting": 7, "tang": 123 } } | ||
b = { "foo": [1,3,4], "bar": {"tang": 126, "hello": "world" } } | ||
d1 = diff(a, b) | ||
|
||
d2 = to_clean_dicts(d1) | ||
assert len(d2) == len(d1) | ||
assert all(len(e2) == len(e1) for e1, e2 in zip(d1, d2)) | ||
|
||
j = json.dumps(d1) | ||
d3 = json.loads(j) | ||
assert len(d3) == len(d1) | ||
assert all(len(e3) == len(e1) for e1, e3 in zip(d1, d3)) | ||
assert d2 == d3 |