|
11 | 11 |
|
12 | 12 |
|
13 | 13 | def test_path(): |
14 | | - TypeDef.load(pathlib.Path, '/bin') == pathlib.Path('/bin') |
15 | | - TypeDef.load(os.PathLike, '/bin') == pathlib.Path('/bin') |
16 | | - TypeDef.load(pathlib.PosixPath, '/bin') == pathlib.Path('/bin') |
17 | | - TypeDef.dump(pathlib.Path, pathlib.Path('/bin')) == '/bin' |
| 14 | + assert TypeDef.load(pathlib.Path, '/bin') == pathlib.Path('/bin') |
| 15 | + assert TypeDef.load(os.PathLike, '/bin') == pathlib.Path('/bin') |
| 16 | + assert TypeDef.load(pathlib.PosixPath, '/bin') == pathlib.Path('/bin') |
| 17 | + assert TypeDef.dump(pathlib.Path, pathlib.Path('/bin')) == '/bin' |
18 | 18 |
|
19 | 19 |
|
20 | 20 | def test_any(): |
21 | | - TypeDef.load(typing.Any, 123) == 123 |
22 | | - TypeDef.dump(typing.Any, '456') == '456' |
| 21 | + assert TypeDef.load(typing.Any, 123) == 123 |
| 22 | + assert TypeDef.dump(typing.Any, '456') == '456' |
23 | 23 |
|
24 | 24 |
|
25 | 25 | def test_unsupported_type(): |
@@ -113,7 +113,7 @@ class MyEnum(str, Enum): |
113 | 113 |
|
114 | 114 | assert TypeDef.load(MyEnum, 'state2_val') == MyEnum.state2 |
115 | 115 | assert TypeDef.dump(MyEnum, MyEnum.state1) == 'state1_val' |
116 | | - with pytest.raises(ValidationError, match='is not a valid MyEnum'): |
| 116 | + with pytest.raises(ValidationError, match='is not a valid'): |
117 | 117 | TypeDef.load(MyEnum, 'other') |
118 | 118 | with pytest.raises(ValidationError, match='Expect a enum'): |
119 | 119 | TypeDef.dump(MyEnum, 'state1_val') |
@@ -259,17 +259,3 @@ def __init__(self, a: typing.Union[submodule, ClassConfig[submodule]], |
259 | 259 | {'a': {'a': 1, 'b': 2}, 'b': {'a': 3, 'b': 4, 'c': 5}}).b.c == 5 |
260 | 260 | assert TypeDef.load(ClassConfig[module], |
261 | 261 | {'a': {'a': 1, 'b': 2}, 'b': {'a': 3, 'b': 4, 'c': 5}}).build().b._c == 5 |
262 | | - |
263 | | - |
264 | | -test_path() |
265 | | -test_optional() |
266 | | -test_any() |
267 | | -test_unsupported_type() |
268 | | -test_primitive() |
269 | | -test_list() |
270 | | -test_tuple() |
271 | | -test_dict() |
272 | | -test_enum() |
273 | | -test_dataclass() |
274 | | -test_union() |
275 | | -test_class_config() |
0 commit comments