-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
164 additions
and
30 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
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,22 @@ | ||
"""Tests for the `encoders` module.""" | ||
|
||
import json | ||
|
||
from griffe.encoders import JSONEncoder, json_decoder | ||
from griffe.loader import GriffeLoader | ||
|
||
|
||
def test_minimal_data_is_enough(): | ||
"""Test serialization and de-serialization. | ||
This is an end-to-end test that asserts | ||
we can load back a serialized tree and | ||
infer as much data as within the original tree. | ||
""" | ||
loader = GriffeLoader() | ||
module = loader.load_module("griffe") | ||
minimal = json.dumps(module, cls=JSONEncoder, full=False, indent=2) | ||
full = json.dumps(module, cls=JSONEncoder, full=True, indent=2) | ||
reloaded = json.loads(minimal, object_hook=json_decoder) | ||
assert json.dumps(reloaded, cls=JSONEncoder, full=False, indent=2) == minimal | ||
assert json.dumps(reloaded, cls=JSONEncoder, full=True, indent=2) == full |