def test_off__1(): """ Called with no arguments, it removes all the events. """ emitter = Emitter() emitter.on("raccoon", callable) emitter.on("fox", callable) emitter.off() assert emitter.events() == set()
def test_off__1(): """ Called with no arguments, it removes all the events. """ emitter = Emitter() emitter.on("raccoon", callable) emitter.on("fox", callable) emitter.off() assert emitter.events() == set()
def test_off__4(): """ False event can be removed. """ emitter = Emitter() emitter.on(False, callable) assert False in emitter.events() emitter.off(False) assert False not in emitter.events()
def test_off__5(): """ True event can be removed. """ emitter = Emitter() emitter.on(True, callable) assert True in emitter.events() emitter.off(True) assert True not in emitter.events()
def test_off__4(): """ False event can be removed. """ emitter = Emitter() emitter.on(False, callable) assert False in emitter.events() emitter.off(False) assert False not in emitter.events()
def test_off__7(): """ A listener of the True event can be removed. """ emitter = Emitter() emitter.on(True, callable) assert callable in emitter.listeners(True) emitter.off(True, callable) assert callable not in emitter.listeners(True)
def test_off__6(): """ A listener of the False event can be removed. """ emitter = Emitter() emitter.on(False, callable) assert callable in emitter.listeners(False) emitter.off(False, callable) assert callable not in emitter.listeners(False)
def test_off__7(): """ A listener of the True event can be removed. """ emitter = Emitter() emitter.on(True, callable) assert callable in emitter.listeners(True) emitter.off(True, callable) assert callable not in emitter.listeners(True)
def test_off__6(): """ A listener of the False event can be removed. """ emitter = Emitter() emitter.on(False, callable) assert callable in emitter.listeners(False) emitter.off(False, callable) assert callable not in emitter.listeners(False)
def test_off__5(): """ True event can be removed. """ emitter = Emitter() emitter.on(True, callable) assert True in emitter.events() emitter.off(True) assert True not in emitter.events()
def test_off__13(): """ Delete the event if no more listeners. """ emitter = Emitter() emitter.on("event", callable) assert "event" in emitter.events() emitter.off("event", callable) assert emitter.events() == set()
def test_off__13(): """ Delete the event if no more listeners. """ emitter = Emitter() emitter.on("event", callable) assert "event" in emitter.events() emitter.off("event", callable) assert emitter.events() == set()
def test_off__3(): """ Called with 2 arguments, it removes the specified listener of the specified event. """ emitter = Emitter() emitter.on("event", callable) emitter.on("event", str) emitter.off("event", callable) listeners = emitter.listeners("event") assert callable not in listeners assert str in listeners
def test_off__3(): """ Called with 2 arguments, it removes the specified listener of the specified event. """ emitter = Emitter() emitter.on("event", callable) emitter.on("event", str) emitter.off("event", callable) listeners = emitter.listeners("event") assert callable not in listeners assert str in listeners
def test_off__2(): """ When called with 1 argument, it removes only the listeners of the specified event. """ emitter = Emitter() emitter.on("event", callable) emitter.on("event", str) emitter.on("raccoon", callable) emitter.on("raccoon", str) emitter.off("event") assert emitter.listeners("event") == [] assert callable in emitter.listeners("raccoon") assert str in emitter.listeners("raccoon")
def test_off__2(): """ When called with 1 argument, it removes only the listeners of the specified event. """ emitter = Emitter() emitter.on("event", callable) emitter.on("event", str) emitter.on("raccoon", callable) emitter.on("raccoon", str) emitter.off("event") assert emitter.listeners("event") == [] assert callable in emitter.listeners("raccoon") assert str in emitter.listeners("raccoon")
def test_off__12(): """ Returns True if the specified listener has been detached. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event", callable) is True
def test_off__11(): """ Returns True if trying to detach a non-existent listener. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event", bool) is True
def test_off__10(): """ Returns True if the specified event has been deleted. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event") is True
def test_off__10(): """ Returns True if the specified event has been deleted. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event") is True
def test_off__11(): """ Returns True if trying to detach a non-existent listener. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event", bool) is True
def test_off__12(): """ Returns True if the specified listener has been detached. """ emitter = Emitter() emitter.on("event", callable) assert emitter.off("event", callable) is True
def test_off__8(): """ Returns True if all events are deleted. """ emitter = Emitter() emitter.on("event1", callable) emitter.on("event2", callable) assert emitter.off() is True
def test_off__8(): """ Returns True if all events are deleted. """ emitter = Emitter() emitter.on("event1", callable) emitter.on("event2", callable) assert emitter.off() is True
def test_off__9(): """ Returns True if trying to remove a non-existent event. """ emitter = Emitter() assert emitter.off("unknown") is True
def test_off__9(): """ Returns True if trying to remove a non-existent event. """ emitter = Emitter() assert emitter.off("unknown") is True