本文整理汇总了Python中emitter.Emitter.on方法的典型用法代码示例。如果您正苦于以下问题:Python Emitter.on方法的具体用法?Python Emitter.on怎么用?Python Emitter.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emitter.Emitter
的用法示例。
在下文中一共展示了Emitter.on方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_events__5
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_events__5():
"""
Should not return the original object, but a copy.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.events() is not emitter.events()
示例2: test_events__3
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_events__3():
"""
False event can be retrieved.
"""
emitter = Emitter()
emitter.on(False, callable)
assert False in emitter.events()
示例3: test_listeners__4
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_listeners__4():
"""
Get the listeners for the False event.
"""
emitter = Emitter()
emitter.on(False, callable)
assert callable in emitter.listeners(False)
示例4: test_off__10
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [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
示例5: test_listeners__6
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_listeners__6():
"""
Should not return the original object, but a copy.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.listeners("event") is not emitter.listeners("event")
示例6: test_off__11
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [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
示例7: test_off__12
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [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
示例8: test_events__4
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_events__4():
"""
True event can be retrieved.
"""
emitter = Emitter()
emitter.on(True, callable)
assert True in emitter.events()
示例9: test_listeners__5
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_listeners__5():
"""
Get the listeners for the True event.
"""
emitter = Emitter()
emitter.on(True, callable)
assert callable in emitter.listeners(True)
示例10: test_on__3
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_on__3():
"""
False is a valid event.
"""
emitter = Emitter()
emitter.on(False, callable)
assert False in emitter.events()
示例11: test_emit__5
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_emit__5():
"""
Returns True when emitting an event.
"""
emitter = Emitter()
emitter.on("event", callable)
result = emitter.emit("event")
assert result is True
示例12: test_on__1
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_on__1():
"""
User cannot register a None event.
"""
emitter = Emitter()
with pytest.raises(ValueError):
emitter.on(None, callable)
示例13: test_off__8
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [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
示例14: test_on__4
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_on__4():
"""
A string is a valid event.
"""
emitter = Emitter()
emitter.on("event", callable)
assert "event" in emitter.events()
示例15: test_on__2
# 需要导入模块: from emitter import Emitter [as 别名]
# 或者: from emitter.Emitter import on [as 别名]
def test_on__2():
"""
True is a valid event.
"""
emitter = Emitter()
emitter.on(True, callable)
assert True in emitter.events()