コード例 #1
0
    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])
コード例 #2
0
 def test___repr__(self) -> None:
     m = bcpi.InstanceDefault(_TestModel, x=10, z=[10])
     assert repr(m) == "<Instance: _util_property._TestModel(x=10, z=[10])>"
コード例 #3
0
    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))
コード例 #4
0
 class ExplicitDefault(HasProps):
     m = bcpi.Instance(_TestModel,
                       default=bcpi.InstanceDefault(_TestModel, x=10))