• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mockito.verify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mockito.verify函数的典型用法代码示例。如果您正苦于以下问题:Python verify函数的具体用法?Python verify怎么用?Python verify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了verify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_catches_exceptions_to_not_break_other_listeners

    def test_catches_exceptions_to_not_break_other_listeners(self):
        when(logger).error(ANY()).thenReturn(None)
        listener = MailboxIndexerListener('INBOX', self.mail_store, mock())

        yield listener.notify_new()

        verify(logger).error(ANY())
开发者ID:Josue23,项目名称:pixelated-user-agent,代码行数:7,代码来源:test_mailbox_indexer_listener.py


示例2: testVerifiesMultipleCallsOnClassmethod

    def testVerifiesMultipleCallsOnClassmethod(self):
        when(Dog).bark().thenReturn("miau!")

        Dog.bark()
        Dog.bark()

        verify(Dog, times=2).bark()
开发者ID:kaste,项目名称:mockito-python,代码行数:7,代码来源:classmethods_test.py


示例3: test_should_raise_exception_when_loading_project_module_and_import_raises_exception

    def test_should_raise_exception_when_loading_project_module_and_import_raises_exception(self):
        when(imp).load_source("build", "spam").thenRaise(ImportError("spam"))

        self.assertRaises(
            PyBuilderException, self.reactor.load_project_module, "spam")

        verify(imp).load_source("build", "spam")
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:7,代码来源:reactor_tests.py


示例4: test_transfert_debite_le_bon_compte

    def test_transfert_debite_le_bon_compte(self):
        """Test si lors du transfert la valeur est bien debitee de la source"""

        amount = 100
        when(self.accountDest).can_accept_credit(amount).thenReturn(True)
        self.transfer.transfer(amount)
        verify(self.accountSrc, times=1).debit(amount)
开发者ID:BenjaminVanRyseghem,项目名称:SVL,代码行数:7,代码来源:test_bank.py


示例5: test_transfert_credite_et_debite_de_la_meme_valeur

 def test_transfert_credite_et_debite_de_la_meme_valeur(self):  
     """Test que lors d'un transfert la valeur debitee et creditee est la meme"""  
     amount = 100
     when(self.accountDest).can_accept_credit(amount).thenReturn(True)
     self.transfer.transfer(amount)
     verify(self.accountDest, times=1).credit(amount)
     verify(self.accountSrc, times=1).debit(amount)
开发者ID:BenjaminVanRyseghem,项目名称:SVL,代码行数:7,代码来源:test_bank.py


示例6: test_rotateMap

 def test_rotateMap(self):
     """
     load the next map/level
     """
     with patch("time.sleep"):
         self.console.rotateMap()
     verify(self.output_mock).write('cyclemap')
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:7,代码来源:test_iourt41.py


示例7: test_should_only_match_py_files_regardless_of_glob

 def test_should_only_match_py_files_regardless_of_glob(self):
     when(os).walk("pet_shop").thenReturn([("pet_shop", [],
                                            ["parrot.txt", "parrot.py", "parrot.pyc", "parrot.py~", "slug.py"])])
     expected_result = ["parrot"]
     actual_result = discover_modules_matching("pet_shop", "*parrot*")
     self.assertEquals(set(expected_result), set(actual_result))
     verify(os).walk("pet_shop")
开发者ID:AnudeepHemachandra,项目名称:pybuilder,代码行数:7,代码来源:utils_tests.py


示例8: test_find_with_link_synonym

 def test_find_with_link_synonym(self):
     finder = ElementFinder()
     browser = mock()
     when(browser).get_current_url().thenReturn("http://localhost/mypage.html")
     finder.find(browser, "test1", tag='link')
     verify(browser).find_elements_by_xpath(
         "//a[(@id='test1' or @name='test1' or @href='test1' or normalize-space(descendant-or-self::text())='test1' or @href='http://localhost/test1')]")
开发者ID:Gaurang033,项目名称:Selenium2Library,代码行数:7,代码来源:test_elementfinder.py


示例9: test_find_with_img

 def test_find_with_img(self):
     finder = ElementFinder()
     browser = mock()
     when(browser).get_current_url().thenReturn("http://localhost/mypage.html")
     finder.find(browser, "test1", tag='img')
     verify(browser).find_elements_by_xpath(
         "//img[(@id='test1' or @name='test1' or @src='test1' or @alt='test1' or @src='http://localhost/test1')]")
开发者ID:Gaurang033,项目名称:Selenium2Library,代码行数:7,代码来源:test_elementfinder.py


示例10: test_delete_backup_fail_delete_segment

 def test_delete_backup_fail_delete_segment(self):
     when(self.swift_client).delete_object(any(), "second").thenRaise(ClientException("foo"))
     self.assertRaises(TroveError, taskmanager_models.BackupTasks.delete_backup, "dummy context", self.backup.id)
     verify(backup_models.Backup, never).delete(self.backup.id)
     self.assertEqual(
         backup_models.BackupState.DELETE_FAILED, self.backup.state, "backup should be in DELETE_FAILED status"
     )
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:test_models.py


示例11: test_find_with_text_field_synonym

 def test_find_with_text_field_synonym(self):
     finder = ElementFinder()
     browser = mock()
     when(browser).get_current_url().thenReturn("http://localhost/mypage.html")
     finder.find(browser, "test1", tag='text field')
     verify(browser).find_elements_by_xpath(
         "//input[@type='text' and (@id='test1' or @name='test1' or @value='test1' or @src='test1' or @src='http://localhost/test1')]")
开发者ID:Gaurang033,项目名称:Selenium2Library,代码行数:7,代码来源:test_elementfinder.py


示例12: testReconfigureStrictMock

    def testReconfigureStrictMock(self):
        when(Dog).bark()  # important first call, inits theMock

        when(Dog, strict=False).waggle().thenReturn('Sure')
        expect(Dog, strict=False).weggle().thenReturn('Sure')


        with pytest.raises(InvocationError):
            when(Dog).wuggle()

        with pytest.raises(InvocationError):
            when(Dog).woggle()

        rex = Dog()
        assert rex.waggle() == 'Sure'
        assert rex.weggle() == 'Sure'

        # For documentation; the inital strict value of the mock will be used
        # here. So the above when(..., strict=False) just assures we can
        # actually *add* an attribute to the mocked object
        with pytest.raises(InvocationError):
            rex.waggle(1)

        verify(Dog).waggle()
        verify(Dog).weggle()
开发者ID:kaste,项目名称:mockito-python,代码行数:25,代码来源:when_interface_test.py


示例13: testSpy2

    def testSpy2(self):
        spy2('os.path.exists')

        import os.path
        assert not os.path.exists('/Foo')

        verify('os.path', times=1).exists('/Foo')
开发者ID:kaste,项目名称:mockito-python,代码行数:7,代码来源:when_interface_test.py


示例14: testVerify

    def testVerify(self):
        when('os.path').exists('/Foo').thenReturn(True)

        import os.path
        os.path.exists('/Foo')

        verify('os.path', times=1).exists('/Foo')
开发者ID:kaste,项目名称:mockito-python,代码行数:7,代码来源:when_interface_test.py


示例15: test_say

 def test_say(self):
     """
     broadcast a message to all players
     """
     self.console.msgPrefix = "B3:"
     self.console.say("something")
     verify(self.output_mock).write('say B3: something')
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:7,代码来源:test_iourt41.py


示例16: test_mark_as_read

    def test_mark_as_read(self):
        mail = LeapMail('id', 'INBOX')
        when(self.mail_store).get_mail(ANY(), include_body=True).thenReturn(mail)
        yield self.mail_service.mark_as_read(1)

        self.assertIn(Status.SEEN, mail.flags)
        verify(self.mail_store).update_mail(mail)
开发者ID:kalfonso,项目名称:pixelated-user-agent,代码行数:7,代码来源:test_mail_service.py


示例17: test_saybig

 def test_saybig(self):
     """
     broadcast a message to all players in a way that will catch their attention.
     """
     self.console.msgPrefix = "B3:"
     self.console.saybig("something")
     verify(self.output_mock).write('bigtext "B3: something"')
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:7,代码来源:test_iourt41.py


示例18: test_delete_mail

    def test_delete_mail(self):
        mail_to_delete = LeapMail(1, 'INBOX')
        when(self.mail_store).get_mail(1, include_body=True).thenReturn(defer.succeed(mail_to_delete))

        yield self.mail_service.delete_mail(1)

        verify(self.mail_store).move_mail_to_mailbox(1, 'TRASH')
开发者ID:kalfonso,项目名称:pixelated-user-agent,代码行数:7,代码来源:test_mail_service.py


示例19: test_getPlayerList

    def test_getPlayerList(self):
        """
        Query the game server for connected players.
        return a dict having players' id for keys and players' data as another dict for values
        """
        when(self.output_mock).write('status', maxRetries=anything()).thenReturn("""
map: ut4_casa
num score ping name            lastmsg  address              qport rate
--- ----- ---- --------------- ------- --------------------- ----- -----
10     0   13 snowwhite        0       192.168.1.11:51034     9992 15000
12     0   10 superman         0       192.168.1.12:53039     9993 15000
""")
        result = self.console.getPlayerList()
        verify(self.output_mock).write('status', maxRetries=anything())
        self.assertDictEqual({'10': {'ip': '192.168.1.11',
                                     'last': '0',
                                     'name': 'snowwhite',
                                     'pbid': None,
                                     'ping': '13',
                                     'port': '51034',
                                     'qport': '9992',
                                     'rate': '15000',
                                     'score': '0',
                                     'slot': '10'},
                              '12': {'ip': '192.168.1.12',
                                     'last': '0',
                                     'name': 'superman',
                                     'pbid': None,
                                     'ping': '10',
                                     'port': '53039',
                                     'qport': '9993',
                                     'rate': '15000',
                                     'score': '0',
                                     'slot': '12'}}
            , result)
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:35,代码来源:test_iourt41.py


示例20: test_should_install_dependency_without_version

    def test_should_install_dependency_without_version(self):
        dependency = Dependency("spam")

        install_dependency(self.logger, self.project, dependency)

        verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
            "pip install 'spam'", any_value(), shell=True)
开发者ID:geraldoandradee,项目名称:pybuilder,代码行数:7,代码来源:install_dependencies_plugin_tests.py



注:本文中的mockito.verify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mockito.verifyNoMoreInteractions函数代码示例发布时间:2022-05-27
下一篇:
Python mockito.unstub函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap