def test_set_max__normal(): sut = Scalar(4) sut.max = 7 assert sut.value == 4 assert sut.max == 7
def test_set_max__lower_than_value(): sut = Scalar(7) sut.max = 4 assert sut.value == 4 assert sut.max == 4
def test_set_min__higher_than_value(): sut = Scalar(5, max=10) sut.min = 7 assert sut.value == 7 assert sut.min == 7
def test_set_min__normal(): sut = Scalar(9) sut.min = 3 assert sut.value == 9 assert sut.min == 3
def test_fraction__full_and_changed(): sut = Scalar(7, max=10) assert sut.fraction == 0.7 sut.value = 10 assert sut.fraction == 1.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
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
def test_set_value__normal(): sut = Scalar(8) sut.value = 5 assert sut.value == 5
def test_set_value__too_high(): sut = Scalar(6) sut.value = 9 assert sut.value == 6
def test_set_value__too_low(): sut = Scalar(4) sut.value = -3.5 assert sut.value == 0