Esempio n. 1
0
    def test_fixed(self):
        param = Parameter(name='test', default=[1, 2, 3, 4])
        assert param.fixed == False == param._fixed

        # Set error
        with pytest.raises(ValueError) as err:
            param.fixed = 3
        assert str(err.value) == \
            "Value must be boolean"

        # Set
        param.fixed = True
        assert param.fixed == True == param._fixed
Esempio n. 2
0
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