-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing new files __init__ and utils.py
- Loading branch information
BibMartin
authored and
BibMartin
committed
Mar 14, 2022
1 parent
4cf4209
commit a637d71
Showing
2 changed files
with
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def doc_equal(doc1, doc2): | ||
"""Test if two JSON-like documents are equel.""" | ||
try: | ||
if isinstance(doc1, dict): | ||
assert isinstance(doc2, dict) | ||
for key in doc1.keys(): | ||
assert key in doc2 and doc_equal(doc1[key], doc2[key]) | ||
elif isinstance(doc1, list): | ||
assert isinstance(doc2, list) and len(doc1) == len(doc2) | ||
for x, y in zip(doc1, doc2): | ||
assert doc_equal(x, y) | ||
else: | ||
assert doc1 == doc2 | ||
return True | ||
except AssertionError: | ||
return False |
Empty file.