Exemple #1
0
def test_integer_bounds():
    p = IntegerParameter('Test', minimum=0, maximum=10)
    p.value = 10
    assert p.value == 10
    with pytest.raises(ValueError):
        p.value = 100  # above maximum
    with pytest.raises(ValueError):
        p.value = -100  # below minimum
def test_integer_bounds():
    p = IntegerParameter('Test', minimum=0, maximum=10)
    p.value = 10
    assert p.value == 10
    with pytest.raises(ValueError):
        p.value = 100  # above maximum
    with pytest.raises(ValueError):
        p.value = -100  # below minimum
Exemple #3
0
def test_integer_value():
    p = IntegerParameter('Test')
    with pytest.raises(ValueError):
        v = p.value  # not set
    with pytest.raises(ValueError):
        p.value = 'a'  # not an integer
    p.value = 0.5  # a float
    assert p.value == 0
    p.value = False  # a boolean
    assert p.value == 0
    p.value = 10
    assert p.value == 10
def test_integer_value():
    p = IntegerParameter('Test')
    with pytest.raises(ValueError):
        v = p.value  # not set
    with pytest.raises(ValueError):
        p.value = 'a'  # not an integer
    p.value = 0.5  # a float
    assert p.value == 0
    p.value = False  # a boolean
    assert p.value == 0
    p.value = 10
    assert p.value == 10
def test_integer_value():
    p = IntegerParameter('Test', units='tests')
    with pytest.raises(ValueError):
        _ = p.value  # not set
    with pytest.raises(ValueError):
        p.value = 'a'  # not an integer
    p.value = 0.5  # a float
    assert p.value == 0
    p.value = False  # a boolean
    assert p.value == 0
    p.value = 10
    assert p.value == 10
    p.value = '5'
    assert p.value == 5
    p.value = '11 tests'
    assert p.value == 11
    assert p.units == 'tests'
    with pytest.raises(ValueError):
        p.value = '31 incorrect units'  # not the correct units