Esempio n. 1
0
 def test_error_logged_if_deferred_not_supported(self):
     test_handler = lambda: defer.Deferred()
     log_events = []
     txlog.addObserver(log_events.append)
     dispatcher.connect(test_handler, test_signal)
     self.manager.send(test_signal)
     self.failUnless(log_events)
     self.failUnless('Cannot return deferreds from signal handler' in str(log_events))
     txlog.removeObserver(log_events.append)
     dispatcher.disconnect(test_handler, test_signal)
Esempio n. 2
0
 def test_error_logged_if_deferred_not_supported(self):
     test_handler = lambda: defer.Deferred()
     log_events = []
     txlog.addObserver(log_events.append)
     dispatcher.connect(test_handler, test_signal)
     self.manager.send(test_signal)
     self.failUnless(log_events)
     self.failUnless(
         'Cannot return deferreds from signal handler' in str(log_events))
     txlog.removeObserver(log_events.append)
     dispatcher.disconnect(test_handler, test_signal)
Esempio n. 3
0
    def _test(self, ok_handler, error_handler, get_result):
        dispatcher.connect(error_handler, signal=test_signal)
        dispatcher.connect(ok_handler, signal=test_signal)
        result = yield defer.maybeDeferred(get_result, test_signal, arg='test')

        self.assertIn(error_handler, self.handlers_called)
        self.assertIn(ok_handler, self.handlers_called)
        self.assertIn(self._log_received, self.handlers_called)
        self.assertEqual(result[0][0], error_handler)
        self.assertIsInstance(result[0][1], Failure)
        self.assertEqual(result[1], (self.ok_handler, 'OK'))

        dispatcher.disconnect(error_handler, signal=test_signal)
        dispatcher.disconnect(ok_handler, signal=test_signal)
Esempio n. 4
0
    def _test(self, ok_handler, error_handler, get_result):
        dispatcher.connect(error_handler, signal=test_signal)
        dispatcher.connect(ok_handler, signal=test_signal)
        result = yield defer.maybeDeferred(get_result, test_signal, arg='test')

        self.assertIn(error_handler, self.handlers_called)
        self.assertIn(ok_handler, self.handlers_called)
        self.assertIn(self._log_received, self.handlers_called)
        self.assertEqual(result[0][0], error_handler)
        self.assertIsInstance(result[0][1], Failure)
        self.assertEqual(result[1], (self.ok_handler, 'OK'))

        dispatcher.disconnect(error_handler, signal=test_signal)
        dispatcher.disconnect(ok_handler, signal=test_signal)
Esempio n. 5
0
 def connect(self, *args, **kwargs):
     kwargs.setdefault('sender', self.sender)
     return dispatcher.connect(*args, **kwargs)
Esempio n. 6
0
 def connect(self, *args, **kwargs):
     kwargs.setdefault('sender', self.sender)
     return dispatcher.connect(*args, **kwargs)