def test_to_from_dict_with_defaults():
dct = {'x': 4, 'y': {'val': 'hello', 'other_val': 'hello 2'}}
obj = Foo.from_dict(dct)
dct2 = obj.to_dict()
assert dct == dct2
dct = {'x': 4, 'z': 'blah', 'y': {'val': 'hello'}}
with pytest.raises(T.TraitError):
Foo.from_dict(dct)
评论列表
文章目录