Add unit test for YAML config loading validation

pull/357/head
nyanpasu64 2018-08-19 15:58:29 -07:00
rodzic 910dd507d9
commit d9555c101e
1 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -71,21 +71,27 @@ b: b
'''
@pytest.mark.xfail(strict=True)
def test_load_type_checking():
def test_argument_validation():
""" Ensure that loading config via YAML catches missing and invalid parameters. """
@register_config
class Foo:
foo: int
bar: int
class Config:
a: int
yaml.load('''\
!Config
a: 1
''')
with pytest.raises(TypeError):
yaml.load('!Config {}')
with pytest.raises(TypeError):
yaml.load('''\
!Config
a: 1
b: 1
''')
s = '''\
!Foo
foo: "foo"
bar: "bar"
'''
with pytest.raises(OvgenError) as e:
print(yaml.load(s))
print(e)
def test_load_post_init():