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