本文整理匯總了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
)