def test_tied(self): param = Parameter(name='test', default=[1, 2, 3, 4]) assert param.tied is False assert param._tied is False # Set error with pytest.raises(TypeError) as err: param.tied = mk.NonCallableMagicMock() assert str( err.value) == "Tied must be a callable or set to False or None" # Set None param.tied = None assert param.tied is None assert param._tied is None # Set False param.tied = False assert param.tied is False assert param._tied is False # Set other tied = mk.MagicMock() param.tied = tied assert param.tied == tied == param._tied
def test_parameter_properties(): """Test if getting / setting of Parameter properties works.""" p = Parameter('alpha', default=1) assert p.name == 'alpha' # Parameter names are immutable with pytest.raises(AttributeError): p.name = 'beta' assert p.fixed is False p.fixed = True assert p.fixed is True assert p.tied is False p.tied = lambda _: 0 p.tied = False assert p.tied is False assert p.min is None p.min = 42 assert p.min == 42 p.min = None assert p.min is None assert p.max is None p.max = 41 assert p.max == 41