本文整理汇总了Python中mockito.unstub函数的典型用法代码示例。如果您正苦于以下问题:Python unstub函数的具体用法?Python unstub怎么用?Python unstub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unstub函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDown
def tearDown(self):
super(SecurityGroupDeleteTest, self).tearDown()
(sec_mod.SecurityGroupInstanceAssociation.
find_by) = self.original_find_by
(sec_mod.SecurityGroupInstanceAssociation.
delete) = self.original_delete
unstub()
示例2: testBuildWithNestedBundles
def testBuildWithNestedBundles(self):
import __builtin__, pickle
from mockito import when, unstub
b = os.path.join('/', 'b.js')
when(__builtin__).open(b).thenReturn(StrIO('b'))
@worker
def content(files, bundle):
for a in files:
assert a == 'a.js'
yield 'a'
@worker
def store(contents, bundle):
for content in contents:
assert content == 'ab'
yield 'ab.js'
env = ets.Environment(mode='development', map_from='/')
nested_bundle = ets.Bundle(assets=['a.js'], env=env,
development=[content])
#keep in mind that build() expects a relative path at the end of the pipe
bundle = ets.Bundle(assets=[nested_bundle, 'b.js'], env=env,
development=[ets.f.read, ets.f.merge, store])
assert bundle.build() == [os.path.join('/', 'ab.js')]
unstub()
示例3: setup_soledad
def setup_soledad(self):
unstub() # making sure all mocks from other tests are reset
# making sure soledad test folder is not there
if (os.path.isdir(soledad_test_folder)):
shutil.rmtree(soledad_test_folder)
self.soledad = initialize_soledad(tempdir=soledad_test_folder)
self.mail_address = "[email protected]"
# resetting soledad querier
SoledadQuerier.reset()
SoledadQuerier.get_instance(soledad=self.soledad)
# setup app
PixelatedMail.from_email_address = self.mail_address
self.app = pixelated.user_agent.app.test_client()
self.account = FakeAccount()
self.pixelated_mailboxes = PixelatedMailBoxes(self.account)
self.mail_sender = mock()
self.tag_index = TagIndex(os.path.join(soledad_test_folder, 'tag_index'))
self.tag_service = TagService(self.tag_index)
self.draft_service = DraftService(self.pixelated_mailboxes)
self.mail_service = MailService(self.pixelated_mailboxes, self.mail_sender, self.tag_service)
SearchEngine.INDEX_FOLDER = soledad_test_folder + '/search_index'
self.search_engine = SearchEngine()
self.search_engine.index_mails(self.mail_service.all_mails())
pixelated.user_agent.mail_service = self.mail_service
pixelated.user_agent.draft_service = self.draft_service
pixelated.user_agent.tag_service = self.tag_service
pixelated.user_agent.search_engine = self.search_engine
示例4: testUnstubInstance
def testUnstubInstance(self):
rex = Dog()
when(rex).bark('Miau').thenReturn('Wuff')
unstub()
assert rex.bark('Miau') == 'Miau!'
示例5: tearDown
def tearDown(self):
super(RedisGuestAgentManagerTest, self).tearDown()
redis_service.RedisAppStatus = self.origin_RedisAppStatus
redis_service.RedisApp.stop_db = self.origin_stop_redis
redis_service.RedisApp.start_redis = self.origin_start_redis
redis_service.RedisApp._install_redis = self.origin_install_redis
unstub()
示例6: tearDown
def tearDown(self):
super(FreshInstanceTasksTest, self).tearDown()
os.remove(self.cloudinit)
os.remove(self.guestconfig)
InstanceServiceStatus.find_by = self.orig_ISS_find_by
DBInstance.find_by = self.orig_DBI_find_by
unstub()
示例7: test_window_info_values_are_strings
def test_window_info_values_are_strings(self):
manager = WindowManager()
driver = mock()
self.mock_window_info(driver, 'id', 'name', 'title', 'url')
driver.current_window_handle = HANDLE
info = manager._get_current_window_info(driver)
self.assertEqual(info, (HANDLE, 'id', 'name', 'title', 'url'))
unstub()
示例8: testUnstubMockedInstanceDoesNotHideTheClass
def testUnstubMockedInstanceDoesNotHideTheClass(self):
when(Dog).waggle().thenReturn('Nope!')
rex = Dog()
when(rex).waggle().thenReturn('Sure!')
assert rex.waggle() == 'Sure!'
unstub()
assert rex.waggle() == 'Wuff!'
示例9: testAddNewMethodOnInstanceInLooseMode
def testAddNewMethodOnInstanceInLooseMode(self):
rex = Dog()
when(rex, strict=False).walk()
rex.walk()
unstub()
with pytest.raises(AttributeError):
rex.walk
示例10: tearDown
def tearDown(self):
super(GuestAgentCouchbaseManagerTest, self).tearDown()
couch_service.CouchbaseAppStatus = self.origin_CouchbaseAppStatus
volume.VolumeDevice.format = self.origin_format
volume.VolumeDevice.mount = self.origin_mount
couch_service.CouchbaseApp.stop_db = self.origin_stop_db
couch_service.CouchbaseApp.start_db = self.origin_start_db
unstub()
示例11: test_absolute_path
def test_absolute_path(self):
"""Test get absolute icons path."""
test_path = "/a/b/Packages"
when(os.path).exists(test_path + "/ColorHighlighter/" + COLOR_HIGHLIGHTER_SETTINGS_NAME).thenReturn(True)
when(sublime).packages_path().thenReturn(test_path)
self.assertEqual(test_path + "/User/ColorHighlighter/icons", path.icons_path(path.ABSOLUTE))
unstub(sublime)
unstub(os.path)
示例12: test_path
def test_path(self):
"""Test get relative data path."""
test_path = "/a/b/Packages"
when(os.path).exists(test_path + "/ColorHighlighter/" + COLOR_HIGHLIGHTER_SETTINGS_NAME).thenReturn(True)
when(sublime).packages_path().thenReturn(test_path)
self.assertEqual("Packages/User/ColorHighlighter", path.data_path(path.RELATIVE))
unstub(sublime)
unstub(os.path)
示例13: test_path_package
def test_path_package(self):
"""Test get relative icons path with a package installation."""
test_path = "/a/b/Packages"
when(os.path).exists(test_path + "/ColorHighlighter/" + COLOR_HIGHLIGHTER_SETTINGS_NAME).thenReturn(False)
when(sublime).packages_path().thenReturn(test_path)
self.assertEqual("Packages/User/Color Highlighter/icons", path.icons_path(path.RELATIVE))
unstub(sublime)
unstub(os.path)
示例14: test_select_by_default_no_match
def test_select_by_default_no_match(self):
manager = WindowManager()
browser = self._make_mock_browser(
{'name': 'win1', 'title': "Title 1", 'url': 'http://localhost/page1.html'},
{'name': 'win2', 'title': "Title 2", 'url': 'http://localhost/page2.html'},
{'name': 'win3', 'title': "Title 3", 'url': 'http://localhost/page3.html'})
self.assertRaises(ValueError, manager.select, browser, "win-1")
unstub()
示例15: test_create_enable_gutter_icons_st2
def test_create_enable_gutter_icons_st2(self): # pylint: disable=invalid-name
"""Test gutter icons can't be enabled in ST2."""
when(st_helper).is_st3().thenReturn(False)
settings = GutterIconsColorHighlighterSettings({
"enabled": True,
})
self.assertFalse(settings.enabled)
unstub(st_helper)