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)
Exemple #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)
Exemple #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)
    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)
Exemple #5
0
 def disconnect_all(self, signal=Any, sender=None):
     sender = self.sender if sender is None else sender
     for receiver in liveReceivers(getAllReceivers(sender, signal)):
         disconnect(receiver, signal=signal, sender=sender)
Exemple #6
0
 def disconnect(self, *args, **kwargs):
     kwargs.setdefault('sender', self.sender)
     return dispatcher.disconnect(*args, **kwargs)
 def disconnect_all(self, signal=Any, sender=None):
     sender = self.sender if sender is None else sender
     for receiver in liveReceivers(getAllReceivers(sender, signal)):
         disconnect(receiver, signal=signal, sender=sender)
 def disconnect(self, *args, **kwargs):
     kwargs.setdefault('sender', self.sender)
     return dispatcher.disconnect(*args, **kwargs)