本文整理汇总了Python中aioxmpp.callbacks.AdHocSignal.fire方法的典型用法代码示例。如果您正苦于以下问题:Python AdHocSignal.fire方法的具体用法?Python AdHocSignal.fire怎么用?Python AdHocSignal.fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aioxmpp.callbacks.AdHocSignal
的用法示例。
在下文中一共展示了AdHocSignal.fire方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_connect_spawn_emits_always
# 需要导入模块: from aioxmpp.callbacks import AdHocSignal [as 别名]
# 或者: from aioxmpp.callbacks.AdHocSignal import fire [as 别名]
def test_connect_spawn_emits_always(self):
signal = AdHocSignal()
mock = CoroutineMock()
@asyncio.coroutine
def coro(*args, **kwargs):
yield from mock(*args, **kwargs)
signal.connect(coro, AdHocSignal.SPAWN_WITH_LOOP(None))
signal.fire("a", 1, b="c")
signal.fire("x")
self.assertSequenceEqual(mock.mock_calls, [])
run_coroutine(asyncio.sleep(0))
run_coroutine(asyncio.sleep(0))
self.assertSequenceEqual(
mock.mock_calls,
[
unittest.mock.call("a", 1, b="c"),
unittest.mock.call("x"),
]
)
示例2: test_fire_removes_stale_references
# 需要导入模块: from aioxmpp.callbacks import AdHocSignal [as 别名]
# 或者: from aioxmpp.callbacks.AdHocSignal import fire [as 别名]
def test_fire_removes_stale_references(self, ref):
signal = AdHocSignal()
fun = unittest.mock.MagicMock()
fun.return_value = None
ref().return_value = None
signal.connect(fun, AdHocSignal.WEAK)
signal.fire()
self.assertFalse(signal._connections)
示例3: test_connect_async
# 需要导入模块: from aioxmpp.callbacks import AdHocSignal [as 别名]
# 或者: from aioxmpp.callbacks.AdHocSignal import fire [as 别名]
def test_connect_async(self):
signal = AdHocSignal()
mock = unittest.mock.MagicMock()
fun = functools.partial(mock)
signal.connect(fun, AdHocSignal.ASYNC_WITH_LOOP(None))
signal.fire()
mock.assert_not_called()
run_coroutine(asyncio.sleep(0))
mock.assert_called_once_with()
示例4: test_connect_and_fire
# 需要导入模块: from aioxmpp.callbacks import AdHocSignal [as 别名]
# 或者: from aioxmpp.callbacks.AdHocSignal import fire [as 别名]
def test_connect_and_fire(self):
signal = AdHocSignal()
fun = unittest.mock.MagicMock()
fun.return_value = None
signal.connect(fun)
signal.fire()
signal.fire()
self.assertSequenceEqual(
[
unittest.mock.call(),
unittest.mock.call(),
],
fun.mock_calls
)