示例#1
0
    def test_init_from_param(self, qtbot, choices, default_value):
        list_param = ListParameter('potato',
                choices=choices,
                default=default_value,
                units='m')
        list_input = ListInput(list_param)
        qtbot.addWidget(list_input)

        assert list_input.isEditable() == False
        assert list_input.value() == default_value
示例#2
0
    def test_init_from_param(self, qtbot, choices, default_value):
        list_param = ListParameter('potato',
                                   choices=choices,
                                   default=default_value,
                                   units='m')
        list_input = ListInput(list_param)
        qtbot.addWidget(list_input)

        assert list_input.isEditable() == False
        assert list_input.value() == default_value
示例#3
0
    def test_setValue_should_update_value(self, qtbot):
        # Test write-read loop: verify value -> index -> value conversion
        choices = [123, 'abc', 0]
        list_param = ListParameter('potato', choices=choices, default=123)
        list_input = ListInput(list_param)
        qtbot.addWidget(list_input)

        for choice in choices:
            list_input.setValue(choice)
            assert list_input.currentText() == str(choice)
            assert list_input.value() == choice
示例#4
0
    def test_setValue_should_update_value(self, qtbot):
        # Test write-read loop: verify value -> index -> value conversion
        choices = [123, 'abc', 0]
        list_param = ListParameter('potato', choices=choices, default=123)
        list_input = ListInput(list_param)
        qtbot.addWidget(list_input)

        for choice in choices:
            list_input.setValue(choice)
            assert list_input.currentText() == str(choice)
            assert list_input.value() == choice
示例#5
0
    def test_init_from_param(self, qtbot, choices, default_value,
                             value_remains_default):
        list_param = ListParameter('potato',
                                   choices=choices,
                                   default=default_value,
                                   units='m')

        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
            list_param.value = choices[2]
            # Enable check that the value is changed after initialization to a non default_value
            check_value = choices[2]

        list_input = ListInput(list_param)
        qtbot.addWidget(list_input)

        assert list_input.isEditable() == False
        assert list_input.value() == check_value