当前位置: 首页>>代码示例>>Python>>正文


Python Emitter.off方法代码示例

本文整理汇总了Python中emitter.Emitter.off方法的典型用法代码示例。如果您正苦于以下问题:Python Emitter.off方法的具体用法?Python Emitter.off怎么用?Python Emitter.off使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emitter.Emitter的用法示例。


在下文中一共展示了Emitter.off方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_off__1

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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()
开发者ID:titouandk,项目名称:emitter.py,代码行数:11,代码来源:test-emitter.py

示例2: test_off__13

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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()
开发者ID:titouandk,项目名称:emitter.py,代码行数:12,代码来源:test-emitter.py

示例3: test_off__7

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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)
开发者ID:titouandk,项目名称:emitter.py,代码行数:12,代码来源:test-emitter.py

示例4: test_off__6

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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)
开发者ID:titouandk,项目名称:emitter.py,代码行数:12,代码来源:test-emitter.py

示例5: test_off__5

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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()
开发者ID:titouandk,项目名称:emitter.py,代码行数:12,代码来源:test-emitter.py

示例6: test_off__4

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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()
开发者ID:titouandk,项目名称:emitter.py,代码行数:12,代码来源:test-emitter.py

示例7: test_off__3

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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
开发者ID:titouandk,项目名称:emitter.py,代码行数:14,代码来源:test-emitter.py

示例8: test_off__2

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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")
开发者ID:titouandk,项目名称:emitter.py,代码行数:17,代码来源:test-emitter.py

示例9: test_off__12

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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
开发者ID:titouandk,项目名称:emitter.py,代码行数:9,代码来源:test-emitter.py

示例10: test_off__11

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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
开发者ID:titouandk,项目名称:emitter.py,代码行数:9,代码来源:test-emitter.py

示例11: test_off__10

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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
开发者ID:titouandk,项目名称:emitter.py,代码行数:9,代码来源:test-emitter.py

示例12: test_off__8

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
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
开发者ID:titouandk,项目名称:emitter.py,代码行数:10,代码来源:test-emitter.py

示例13: test_off__9

# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import off [as 别名]
def test_off__9():
    """
    Returns True if trying to remove a non-existent event.
    """
    emitter = Emitter()
    assert emitter.off("unknown") is True
开发者ID:titouandk,项目名称:emitter.py,代码行数:8,代码来源:test-emitter.py


注:本文中的emitter.Emitter.off方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。