Example #1
0
 async def test_bad_unsubscribe(self):
     """Assert that unsubscribing a handler that isn't registered fails."""
     emitter = EventHub()
     with pytest.raises(NoSuchListenerError):
         emitter.unsubscribe(ExampleEvents.something_happened, self.handler)
Example #2
0
 async def test_unsubscribe_from_event(self):
     """Assert that a handler can be unsubscribed from an event."""
     emitter = EventHub(ExampleEvents)
     emitter.subscribe(emitter.something_happened, self.handler)
     emitter.unsubscribe(emitter.something_happened, self.handler)