예제 #1
0
    def test_derivation_3(self):
        test = NotifyTestObject()

        DerivedCondition = \
            AbstractStateTrackingCondition.derive_type ('DerivedCondition',
                                                        setter = (lambda condition, state:
                                                                      test.simple_handler (state)))

        condition = DerivedCondition(False)
        condition.set(True)
        condition.state = False

        # There is no getter at all, so setter must be called during condition creation.
        test.assert_results(False, True, False)
예제 #2
0
    def test_derivation_3 (self):
        test = NotifyTestObject ()

        DerivedCondition = \
            AbstractStateTrackingCondition.derive_type ('DerivedCondition',
                                                        setter = (lambda condition, state:
                                                                      test.simple_handler (state)))

        condition = DerivedCondition (False)
        condition.set (True)
        condition.state = False

        # There is no getter at all, so setter must be called during condition creation.
        test.assert_results (False, True, False)
예제 #3
0
    def test_derivation_9 (self):
        test = NotifyTestObject ()

        DerivedVariable = \
            AbstractValueTrackingVariable.derive_type ('DerivedVariable',
                                                       setter = (lambda variable, value:
                                                                     test.simple_handler (value)))

        variable = DerivedVariable ()
        variable.set (100)
        variable.value = 'abc'

        # There is no getter at all, so setter must be called during variable creation.
        test.assert_results (None, 100, 'abc')
예제 #4
0
    def test_derivation_2(self):
        test = NotifyTestObject()

        DerivedCondition = \
            AbstractStateTrackingCondition.derive_type ('DerivedCondition',
                                                        getter = lambda condition: False,
                                                        setter = (lambda condition, state:
                                                                      test.simple_handler (state)))

        condition = DerivedCondition()
        condition.set(True)
        condition.state = False

        # The default state is retrieved with the getter function, so the setter must not
        # be called during condition creation.
        test.assert_results(True, False)
예제 #5
0
    def test_derivation_2 (self):
        test = NotifyTestObject ()

        DerivedCondition = \
            AbstractStateTrackingCondition.derive_type ('DerivedCondition',
                                                        getter = lambda condition: False,
                                                        setter = (lambda condition, state:
                                                                      test.simple_handler (state)))

        condition = DerivedCondition ()
        condition.set (True)
        condition.state = False

        # The default state is retrieved with the getter function, so the setter must not
        # be called during condition creation.
        test.assert_results (True, False)
예제 #6
0
    def test_derivation_8 (self):
        test = NotifyTestObject ()

        DerivedVariable = \
            AbstractValueTrackingVariable.derive_type ('DerivedVariable',
                                                       getter = lambda variable: None,
                                                       setter = (lambda variable, value:
                                                                     test.simple_handler (value)))

        variable = DerivedVariable ()
        variable.set (100)
        variable.value = 'abc'

        # The default value is retrieved with the getter function, so the setter must not
        # be called during variable creation.
        test.assert_results (100, 'abc')