def test_boolean_value(): p = BooleanParameter('Test') with pytest.raises(ValueError): v = p.value # not set p.value = 'a' # a string assert p.value == True p.value = 10 # a number assert p.value == True p.value = 0 # zero assert p.value == False p.value = True assert p.value == True
def test_boolean_value(): p = BooleanParameter('Test') with pytest.raises(ValueError): _ = p.value # not set with pytest.raises(ValueError): p.value = 'a' # a string with pytest.raises(ValueError): p.value = 10 # a number other than 0 or 1 p.value = "True" assert p.value is True p.value = "False" assert p.value is False p.value = "true" assert p.value is True p.value = "false" assert p.value is False p.value = 1 # a number assert p.value is True p.value = 0 # zero assert p.value is False p.value = True assert p.value is True
def test_init_from_param(self, qtbot, default_value, value_remains_default): # set up BooleanInput bool_param = BooleanParameter('potato', default=default_value) if (value_remains_default): # Enable check that the value is initialized to default_value check_value = default_value else: # Set to a non default value bool_param.value = not default_value # Enable check that the value is changed after initialization to a non default value check_value = not default_value bool_input = BooleanInput(bool_param) qtbot.addWidget(bool_input) # test assert bool_input.text() == bool_param.name assert bool_input.value() == check_value