本文整理汇总了Python中aioxmpp.callbacks.TagDispatcher.broadcast_error方法的典型用法代码示例。如果您正苦于以下问题:Python TagDispatcher.broadcast_error方法的具体用法?Python TagDispatcher.broadcast_error怎么用?Python TagDispatcher.broadcast_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aioxmpp.callbacks.TagDispatcher
的用法示例。
在下文中一共展示了TagDispatcher.broadcast_error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broadcast_error
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import broadcast_error [as 别名]
def test_broadcast_error(self):
data = unittest.mock.Mock()
error1 = unittest.mock.Mock()
error1.return_value = False
error2 = unittest.mock.Mock()
error2.return_value = False
l1 = TagListener(data, error1)
l2 = TagListener(data, error2)
obj = object()
nh = TagDispatcher()
nh.add_listener("tag1", l1)
nh.add_listener("tag2", l2)
nh.broadcast_error(obj)
nh.broadcast_error(obj)
data.assert_not_called()
self.assertSequenceEqual(
[
unittest.mock.call(obj),
unittest.mock.call(obj),
],
error1.mock_calls
)
self.assertSequenceEqual(
[
unittest.mock.call(obj),
unittest.mock.call(obj),
],
error2.mock_calls
)
示例2: test_add_future
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import broadcast_error [as 别名]
def test_add_future(self):
mock = unittest.mock.Mock()
mock.done.return_value = False
obj = object()
nh = TagDispatcher()
nh.add_future("tag", mock)
nh.unicast("tag", obj)
with self.assertRaises(KeyError):
# futures must be oneshots
nh.unicast("tag", obj)
nh.add_future("tag", mock)
nh.broadcast_error(obj)
with self.assertRaises(KeyError):
# futures must be oneshots
nh.unicast("tag", obj)
self.assertSequenceEqual(
[
unittest.mock.call.done(),
unittest.mock.call.set_result(obj),
unittest.mock.call.done(),
unittest.mock.call.set_exception(obj),
],
mock.mock_calls
)
示例3: test_broadcast_error_skip_invalid
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import broadcast_error [as 别名]
def test_broadcast_error_skip_invalid(self):
obj = object()
l = unittest.mock.Mock()
l.is_valid.return_value = False
nh = TagDispatcher()
nh.add_listener("tag", l)
nh.broadcast_error(obj)
self.assertSequenceEqual(
[
unittest.mock.call.is_valid()
],
l.mock_calls
)
示例4: test_broadcast_error_to_cancelled_oneshot
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import broadcast_error [as 别名]
def test_broadcast_error_to_cancelled_oneshot(self):
data = unittest.mock.Mock()
error = unittest.mock.Mock()
obj = object()
l = OneshotTagListener(data, error)
nh = TagDispatcher()
nh.add_listener("tag", l)
l.cancel()
nh.broadcast_error(obj)
with self.assertRaises(KeyError):
nh.unicast("tag", obj)
self.assertSequenceEqual(
[],
error.mock_calls
)
self.assertFalse(data.mock_calls)
示例5: test_broadcast_error_removes_on_true_result
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import broadcast_error [as 别名]
def test_broadcast_error_removes_on_true_result(self):
data = unittest.mock.Mock()
error1 = unittest.mock.Mock()
error1.return_value = True
l1 = TagListener(data, error1)
obj = object()
nh = TagDispatcher()
nh.add_listener("tag1", l1)
nh.broadcast_error(obj)
nh.broadcast_error(obj)
data.assert_not_called()
self.assertSequenceEqual(
[
unittest.mock.call(obj),
],
error1.mock_calls
)