def testUnregisterIfNotRegistered(self): """EventManager.unregister complains if not registered.""" event_manager = EventManager() listener = SubListener() self.assertRaises(evtman.NotRegisteredError, event_manager.unregister, listener) event_manager.register(listener) event_manager.unregister(listener) self.assertRaises(evtman.NotRegisteredError, event_manager.unregister, listener)
def testUnregister(self): """EventManager.unregister removes the handlers of a listener.""" event_manager = EventManager() listener1 = SubListener() listener2 = SubListener() event_manager.register(listener1) event_manager.register(listener2) event_manager.unregister(listener1) self.assertFalse(listener1 in event_manager._handlers["SubEvent"]) self.assertTrue(listener2 in event_manager._handlers["SubEvent"])