Пример #1
0
def test_set_max__normal():
    sut = Scalar(4)

    sut.max = 7

    assert sut.value == 4
    assert sut.max == 7
Пример #2
0
def test_set_max__lower_than_value():
    sut = Scalar(7)

    sut.max = 4

    assert sut.value == 4
    assert sut.max == 4
Пример #3
0
def test_set_min__higher_than_value():
    sut = Scalar(5, max=10)

    sut.min = 7

    assert sut.value == 7
    assert sut.min == 7
Пример #4
0
def test_set_min__normal():
    sut = Scalar(9)

    sut.min = 3

    assert sut.value == 9
    assert sut.min == 3
Пример #5
0
def test_fraction__full_and_changed():
    sut = Scalar(7, max=10)

    assert sut.fraction == 0.7

    sut.value = 10

    assert sut.fraction == 1.0
Пример #6
0
def test_set_max__lower_than_min():
    sut = Scalar(5)

    try:
        sut.max = -2
    except ValueError as err:
        assert err.message == 'max must be >= min'
    else:
        assert False
Пример #7
0
def test_set_min__higher_than_max():
    sut = Scalar(5)

    try:
        sut.min = 7
    except ValueError as err:
        assert err.message == "min must be <= max"
    else:
        assert False
Пример #8
0
def test_set_value__normal():
    sut = Scalar(8)

    sut.value = 5

    assert sut.value == 5
Пример #9
0
def test_set_value__too_high():
    sut = Scalar(6)

    sut.value = 9

    assert sut.value == 6
Пример #10
0
def test_set_value__too_low():
    sut = Scalar(4)

    sut.value = -3.5

    assert sut.value == 0