Ejemplo n.º 1
0
 def testGetHandlers(self):
     """Listener.isHandler return handlers."""
     listener = Listener()
     handlers = listener.getHandlers()
     self.assertEquals(len(handlers), 1)
     # Here it's one because every Listener listens to the dummy "Event"
     # event.
     #
     listener = SubListener()
     handlers = listener.getHandlers()
     self.assertEquals(len(handlers), 2)
     self.assertEquals(handlers['SubEvent'], listener.onSubEvent)
Ejemplo n.º 2
0
 def testGetHandlers(self):
     """Listener.isHandler return handlers."""
     listener = Listener()
     handlers = listener.getHandlers()
     self.assertEquals(len(handlers), 1)
     # Here it's one because every Listener listens to the dummy "Event"
     # event.
     #
     listener = SubListener()
     handlers = listener.getHandlers()
     self.assertEquals(len(handlers), 2)
     self.assertEquals(handlers['SubEvent'], listener.onSubEvent)
Ejemplo n.º 3
0
    def testPostAndPump(self):
        """EventManager.pump sends all the posted events to all the listeners.

        """
        SubListener.egg_plus_spam = 0
        event_manager = EventManager()
        listener1 = SubListener()
        listener2 = SubListener()
        event_manager.register(listener1)
        event_manager.register(listener2)
        event_manager.register(Listener())  # This one won't react.
        event1 = SubEvent(666, 42)
        event2 = SubEvent(13, 7)
        event_manager.post(event1)
        event_manager.post(event2)
        event_manager.post(Event())  # This one won't trigger anything.
        event_manager.pump()
        self.assertEquals(SubListener.egg_plus_spam, (666 + 42 + 13 + 7) * 2)
Ejemplo n.º 4
0
 def __init__(self):
     Listener.__init__(self)
Ejemplo n.º 5
0
 def testInit(self):
     """Listener.__init__ doesn't crash."""
     unused = Listener()
Ejemplo n.º 6
0
 def __init__(self):
     Listener.__init__(self)