예제 #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)
예제 #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)
예제 #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)
예제 #4
0
 def __init__(self):
     Listener.__init__(self)
예제 #5
0
 def testInit(self):
     """Listener.__init__ doesn't crash."""
     unused = Listener()
예제 #6
0
 def __init__(self):
     Listener.__init__(self)