本文整理汇总了Python中mockito.verify函数的典型用法代码示例。如果您正苦于以下问题:Python verify函数的具体用法?Python verify怎么用?Python verify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了verify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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())
示例2: testVerifiesMultipleCallsOnClassmethod
def testVerifiesMultipleCallsOnClassmethod(self):
when(Dog).bark().thenReturn("miau!")
Dog.bark()
Dog.bark()
verify(Dog, times=2).bark()
示例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")
示例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)
示例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)
示例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')
示例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")
示例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')]")
示例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')]")
示例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"
)
示例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')]")
示例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()
示例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')
示例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')
示例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')