本文整理汇总了Python中aioxmpp.callbacks.TagDispatcher.unicast_error方法的典型用法代码示例。如果您正苦于以下问题:Python TagDispatcher.unicast_error方法的具体用法?Python TagDispatcher.unicast_error怎么用?Python TagDispatcher.unicast_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aioxmpp.callbacks.TagDispatcher
的用法示例。
在下文中一共展示了TagDispatcher.unicast_error方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unicast_error
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import unicast_error [as 别名]
def test_unicast_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.unicast_error("tag1", obj)
data.assert_not_called()
self.assertSequenceEqual(
[
unittest.mock.call(obj),
],
error1.mock_calls
)
self.assertSequenceEqual(
[
],
error2.mock_calls
)
示例2: test_unicast_error_skip_and_remove_invalid_and_raise_KeyError
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import unicast_error [as 别名]
def test_unicast_error_skip_and_remove_invalid_and_raise_KeyError(self):
obj = object()
l = unittest.mock.Mock()
l.is_valid.return_value = False
nh = TagDispatcher()
nh.add_listener("tag", l)
with self.assertRaises(KeyError):
nh.unicast_error("tag", obj)
self.assertSequenceEqual(
[
unittest.mock.call.is_valid()
],
l.mock_calls
)
示例3: test_unicast_error_removes_on_true_result
# 需要导入模块: from aioxmpp.callbacks import TagDispatcher [as 别名]
# 或者: from aioxmpp.callbacks.TagDispatcher import unicast_error [as 别名]
def test_unicast_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.unicast_error("tag1", obj)
with self.assertRaises(KeyError):
nh.unicast_error("tag1", obj)
data.assert_not_called()
self.assertSequenceEqual(
[
unittest.mock.call(obj),
],
error1.mock_calls
)