def test_asdict(self): schema = Schema(dynamic=True) schema.x = Field() schema.sub1.y = Field() schema.a = VirtualField(lambda cfg: 100) config = schema() config.x = 1 config.sub1.y = 2 config.z = 3 assert asdict(config) == {'x': 1, 'z': 3, 'sub1': {'y': 2}}
def test_asdict_virtual(self): schema = Schema() schema.x = Field() schema.sub1.y = Field() schema.a = VirtualField(lambda cfg: 100) config = schema() config.x = 1 config.sub1.y = 2 assert asdict(config, virtual=True) == { 'x': 1, 'sub1': { 'y': 2 }, 'a': 100 }