示例#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()
示例#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()
示例#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()
示例#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()
示例#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()
示例#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)
示例#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)
示例#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)
示例#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)
示例#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()
示例#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()
示例#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()
示例#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
示例#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
示例#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")
示例#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")
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#25
0
def test_off__9():
    """
    Returns True if trying to remove a non-existent event.
    """
    emitter = Emitter()
    assert emitter.off("unknown") is True
示例#26
0
def test_off__9():
    """
    Returns True if trying to remove a non-existent event.
    """
    emitter = Emitter()
    assert emitter.off("unknown") is True