Пример #1
0
    def test_setValue_within_range_should_set(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-10, maximum=10, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test
        sci_input.setValue(5)
        assert sci_input.value() == 5
Пример #2
0
    def test_setValue_within_range_should_set(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-10, maximum=10, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test
        sci_input.setValue(5)
        assert sci_input.value() == 5
Пример #3
0
    def test_setValue_out_of_range_should_constrain(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test
        sci_input.setValue(1024)
        assert sci_input.value() == 1000

        sci_input.setValue(-1024)
        assert sci_input.value() == -1000
Пример #4
0
    def test_setValue_out_of_range_should_constrain(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test
        sci_input.setValue(1024)
        assert sci_input.value() == 1000

        sci_input.setValue(-1024)
        assert sci_input.value() == -1000
Пример #5
0
    def test_setValue_should_update_param(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=10.0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        with mock.patch('test_inputs.FloatParameter.value',
                new_callable=mock.PropertyMock,
                return_value=10.0) as p:
            # test
            sci_input.setValue(5.0)
            sci_input.parameter # lazy update
            p.assert_called_once_with(5.0)
Пример #6
0
    def test_setValue_within_range_should_set_regression_118(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test - validate min/max beyond QDoubleSpinBox defaults
        # QDoubleSpinBox defaults are 0 to 99.9 - so test value >= 100
        sci_input.setValue(999)
        assert sci_input.value() == 999

        sci_input.setValue(-999)
        assert sci_input.value() == -999
Пример #7
0
    def test_setValue_should_update_param(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=10.0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        with mock.patch('test_inputs.FloatParameter.value',
                new_callable=mock.PropertyMock,
                return_value=10.0) as p:
            # test
            sci_input.setValue(5.0)
            sci_input.parameter # lazy update
            p.assert_called_once_with(5.0)
Пример #8
0
    def test_setValue_within_range_should_set_regression_118(self, qtbot):
        float_param = FloatParameter('potato',
            minimum=-1000, maximum=1000, default=0)
        sci_input = ScientificInput(float_param)
        qtbot.addWidget(sci_input)

        # test - validate min/max beyond QDoubleSpinBox defaults
        # QDoubleSpinBox defaults are 0 to 99.9 - so test value >= 100
        sci_input.setValue(999)
        assert sci_input.value() == 999

        sci_input.setValue(-999)
        assert sci_input.value() == -999