當前位置: 首頁>>代碼示例>>Python>>正文


Python TagDispatcher.broadcast_error方法代碼示例

本文整理匯總了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
        )
開發者ID:horazont,項目名稱:aioxmpp,代碼行數:36,代碼來源:test_callbacks.py

示例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
        )
開發者ID:horazont,項目名稱:aioxmpp,代碼行數:29,代碼來源:test_callbacks.py

示例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
     )
開發者ID:horazont,項目名稱:aioxmpp,代碼行數:15,代碼來源:test_callbacks.py

示例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)
開發者ID:horazont,項目名稱:aioxmpp,代碼行數:23,代碼來源:test_callbacks.py

示例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
        )
開發者ID:horazont,項目名稱:aioxmpp,代碼行數:24,代碼來源:test_callbacks.py


注:本文中的aioxmpp.callbacks.TagDispatcher.broadcast_error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。