def test_init(self) -> None: with pytest.raises(TypeError): bcpi.InstanceDefault() bcpi.InstanceDefault(_TestModel) bcpi.InstanceDefault(_TestModel, x=10) bcpi.InstanceDefault(_TestModel, x=10, z=[10])
def test___repr__(self) -> None: m = bcpi.InstanceDefault(_TestModel, x=10, z=[10]) assert repr(m) == "<Instance: _util_property._TestModel(x=10, z=[10])>"
def test___call__(self, kwargs) -> None: default = _TestModel() m = bcpi.InstanceDefault(_TestModel, **kwargs)() for prop in m.properties(): assert getattr(m, prop) == kwargs.get(prop, getattr(default, prop))
class ExplicitDefault(HasProps): m = bcpi.Instance(_TestModel, default=bcpi.InstanceDefault(_TestModel, x=10))