-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_coverage.py
More file actions
32 lines (22 loc) · 996 Bytes
/
test_coverage.py
File metadata and controls
32 lines (22 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from fractured_json import CommentPolicy, FracturedJsonOptions, NumberListAlignment
def test_eq_and_hash():
assert CommentPolicy.REMOVE != CommentPolicy.PRESERVE
assert NumberListAlignment.LEFT == 0
a = dict()
a[CommentPolicy.REMOVE] = "test"
assert list(a.keys())[0].name == "REMOVE"
assert list(a.keys())[0].value == 1
def test_from_dotnet():
with pytest.raises(ValueError, match="dotnet_instance cannot be None"):
FracturedJsonOptions._from_dotnet(None)
class FakeInstance:
def GetType(self):
return "FakeInstance"
with pytest.raises(TypeError, match="Expected .*FracturedJsonOptions"):
FracturedJsonOptions._from_dotnet(FakeInstance())
def test_from_dotnet_success():
options = FracturedJsonOptions()
wrapper = FracturedJsonOptions._from_dotnet(options._dotnet_instance)
assert isinstance(wrapper, FracturedJsonOptions)
assert wrapper._dotnet_instance is options._dotnet_instance