Example #1
0
    def test_watcher_condition_1 (self):
        test = NotifyTestObject ()

        watcher = WatcherCondition ()
        watcher.store (test.simple_handler)

        condition = Condition (True)
        watcher.watch (condition)

        self.assert_(watcher.watched_condition is condition)

        condition.state = False

        test.assert_results (False, True, False)
Example #2
0
    def test_watcher_condition_2(self):
        test = NotifyTestObject()

        condition1 = Condition(True)
        condition2 = Condition(False)
        condition3 = Condition(False)

        watcher = WatcherCondition(condition1)
        watcher.store(test.simple_handler)

        watcher.watch(condition2)
        watcher.watch(condition3)
        watcher.watch(None)

        self.assert_(watcher.watched_condition is None)

        # Last two watch() calls must not change watcher's state.
        test.assert_results(True, False)
Example #3
0
    def test_watcher_condition_1(self):
        test = NotifyTestObject()

        watcher = WatcherCondition()
        watcher.store(test.simple_handler)

        condition = Condition(True)
        watcher.watch(condition)

        self.assert_(watcher.watched_condition is condition)

        condition.state = False

        test.assert_results(False, True, False)
Example #4
0
    def test_watcher_condition_2 (self):
        test = NotifyTestObject ()

        condition1 = Condition (True)
        condition2 = Condition (False)
        condition3 = Condition (False)

        watcher = WatcherCondition (condition1)
        watcher.store (test.simple_handler)

        watcher.watch (condition2)
        watcher.watch (condition3)
        watcher.watch (None)

        self.assert_(watcher.watched_condition is None)

        # Last two watch() calls must not change watcher's state.
        test.assert_results (True, False)
Example #5
0
    def test_watcher_condition_error_3(self):
        condition = Condition(True)
        watcher = WatcherCondition(condition)

        self.assertRaises(ValueError, lambda: watcher.watch(watcher))
        self.assert_(watcher.watched_condition is condition)
Example #6
0
 def test_watcher_condition_error_2(self):
     watcher = WatcherCondition()
     self.assertRaises(TypeError, lambda: watcher.watch(25))
Example #7
0
 def test_watcher_condition_error_1(self):
     self.assertRaises(TypeError, lambda: WatcherCondition(25))
Example #8
0
    def test_watcher_condition_error_3 (self):
        condition = Condition (True)
        watcher   = WatcherCondition (condition)

        self.assertRaises (ValueError, lambda: watcher.watch (watcher))
        self.assert_      (watcher.watched_condition is condition)
Example #9
0
 def test_watcher_condition_error_2 (self):
     watcher = WatcherCondition ()
     self.assertRaises (TypeError, lambda: watcher.watch (25))