Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_event():
ename = 'test'
m = mock.Mock()
events.subscribe(ename)(m)
events.trigger(ename)()
m.assert_called_once()
del events.__events[ename]
def test_disable_event():
ename = 'test'
m = mock.Mock()
noop, noop_m = events.noop, mock.Mock()
events.noop = noop_m
events.subscribe(ename)(m)
events.disable(ename)
assert m.called is False
assert ename in events.__disabled_events
assert events.trigger(ename) == events.noop
assert events.trigger(ename)() == events.noop()
assert m.called is False
assert noop_m.is_called_once()
events.enable(ename)
assert ename not in events.__disabled_events
del events.__events[ename]
events.noop = noop