Example #1
0
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()
Example #2
0
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()
Example #3
0
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()
Example #4
0
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()
Example #5
0
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()
Example #6
0
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)
Example #7
0
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)
Example #8
0
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)
Example #9
0
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)
Example #10
0
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()
Example #11
0
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()
Example #12
0
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()
Example #13
0
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
Example #14
0
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
Example #15
0
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")
Example #16
0
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")
Example #17
0
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
Example #18
0
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
Example #19
0
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
Example #20
0
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
Example #21
0
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
Example #22
0
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
Example #23
0
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
Example #24
0
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
Example #25
0
def test_off__9():
    """
    Returns True if trying to remove a non-existent event.
    """
    emitter = Emitter()
    assert emitter.off("unknown") is True
Example #26
0
def test_off__9():
    """
    Returns True if trying to remove a non-existent event.
    """
    emitter = Emitter()
    assert emitter.off("unknown") is True