本文整理匯總了Python中asynctest.mock.Mock.id方法的典型用法代碼示例。如果您正苦於以下問題:Python Mock.id方法的具體用法?Python Mock.id怎麽用?Python Mock.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類asynctest.mock.Mock
的用法示例。
在下文中一共展示了Mock.id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_cached_stranger__cached
# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import id [as 別名]
def test_get_cached_stranger__cached(self):
cached_stranger = Mock()
cached_stranger.id = 31416
self.stranger_service._strangers_cache[31416] = cached_stranger
stranger = Mock()
stranger.id = 31416
self.assertEqual(self.stranger_service.get_cached_stranger(stranger), cached_stranger)
示例2: test_on_chat_message__text_stranger_has_blocked_the_bot
# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import id [as 別名]
async def test_on_chat_message__text_stranger_has_blocked_the_bot(self, handle_command_mock):
from randtalkbot.stranger_handler import LOGGER
from randtalkbot.stranger_handler import Message
from randtalkbot.stranger_handler import telepot
from randtalkbot.stranger_handler import StrangerError
telepot.glance.return_value = 'text', 'private', 31416
self.stranger_setup_wizard.handle.return_value = False
message_json = {
'text': 'message_text',
}
Message.return_value.command = None
partner = Mock()
partner.id = 27183
self.stranger.get_partner = Mock(return_value=partner)
self.stranger.id = 31416
self.stranger.send_to_partner = CoroutineMock(side_effect=TelegramError({}, '', 0))
await self.stranger_handler.on_chat_message(message_json)
LOGGER.warning(
'Send text. Can\'t send to partned: %d -> %d',
31416,
27183
)
self.sender.send_notification.assert_called_once_with(
'Your partner has blocked me! How did you do that?!',
)