-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Marco-Sulla/coverage
Coverage
- Loading branch information
Showing
10 changed files
with
128 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ test/core.* | |
.eggs/ | ||
.idea/ | ||
.vs/ | ||
.coverage |
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,2 @@ | ||
rm -rf build dist *.egg-info | ||
FROZENDICT_PURE_PY=1 ./setup.py $* |
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
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,48 @@ | ||
import json | ||
|
||
import frozendict as cool | ||
import pytest | ||
from frozendict import frozendict | ||
from frozendict.monkeypatch import MonkeypatchWarning | ||
|
||
|
||
class A: | ||
pass | ||
|
||
|
||
@pytest.fixture | ||
def object_to_serialize(): | ||
return frozendict() | ||
|
||
|
||
@pytest.fixture | ||
def object_to_serialize_2(): | ||
return A() | ||
|
||
|
||
@pytest.fixture | ||
def serialized_object(): | ||
return "{}" | ||
|
||
|
||
def test_get_json_encoder( | ||
object_to_serialize, | ||
object_to_serialize_2, | ||
serialized_object, | ||
): | ||
if cool.c_ext: | ||
cool.monkeypatch.patchOrUnpatchJson(patch=True) | ||
else: | ||
with pytest.warns(MonkeypatchWarning): | ||
cool.monkeypatch.patchOrUnpatchJson(patch=True, warn=True) | ||
|
||
assert json.dumps(object_to_serialize) == serialized_object | ||
|
||
with pytest.raises(TypeError): | ||
json.dumps(object_to_serialize_2) | ||
|
||
cool.monkeypatch.patchOrUnpatchJson(patch=False, warn=False) | ||
|
||
if cool.c_ext: | ||
with pytest.raises(TypeError): | ||
json.dumps(object_to_serialize) |