Esempio n. 1
0
    def test_watcher_variable_1 (self):
        test = NotifyTestObject ()

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

        variable = Variable ('abc')
        watcher.watch (variable)

        self.assert_(watcher.watched_variable is variable)

        variable.value = 60

        test.assert_results (None, 'abc', 60)
Esempio n. 2
0
    def test_watcher_variable_2 (self):
        test = NotifyTestObject ()

        variable1 = Variable ([])
        variable2 = Variable ('string')
        variable3 = Variable ('string')

        watcher = WatcherVariable (variable1)
        watcher.store (test.simple_handler)

        watcher.watch (variable2)
        watcher.watch (variable3)
        watcher.watch (None)

        self.assert_(watcher.watched_variable is None)

        # Later two watch() calls must not change watcher's value.
        test.assert_results ([], 'string', None)
Esempio n. 3
0
    def test_watcher_variable_error_3 (self):
        variable = Variable ()
        watcher  = WatcherVariable (variable)

        self.assertRaises (ValueError, lambda: watcher.watch (watcher))
        self.assert_      (watcher.watched_variable is variable)
Esempio n. 4
0
 def test_watcher_variable_error_2 (self):
     watcher = WatcherVariable ()
     self.assertRaises (TypeError, lambda: watcher.watch (25))