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

Python mockito.unstub函数代码示例

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

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



在下文中一共展示了unstub函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:test_security_group.py


示例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()
开发者ID:kaste,项目名称:ass.ets,代码行数:31,代码来源:assets_test.py


示例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
开发者ID:vintrepid,项目名称:pixelated-user-agent,代码行数:34,代码来源:integration_helper.py


示例4: testUnstubInstance

    def testUnstubInstance(self):
        rex = Dog()
        when(rex).bark('Miau').thenReturn('Wuff')

        unstub()

        assert rex.bark('Miau') == 'Miau!'
开发者ID:kaste,项目名称:mockito-python,代码行数:7,代码来源:instancemethods_test.py


示例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()
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:test_manager.py


示例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()
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:test_models.py


示例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()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:8,代码来源:test_windowmananger_window_info.py


示例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!'
开发者ID:kaste,项目名称:mockito-python,代码行数:8,代码来源:instancemethods_test.py


示例9: testAddNewMethodOnInstanceInLooseMode

    def testAddNewMethodOnInstanceInLooseMode(self):
        rex = Dog()
        when(rex, strict=False).walk()
        rex.walk()

        unstub()
        with pytest.raises(AttributeError):
            rex.walk
开发者ID:kaste,项目名称:mockito-python,代码行数:8,代码来源:instancemethods_test.py


示例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()
开发者ID:abramley,项目名称:trove,代码行数:8,代码来源:test_couchbase_manager.py


示例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)
开发者ID:DavidPesta,项目名称:ColorHighlighter,代码行数:8,代码来源:test_path.py


示例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)
开发者ID:DavidPesta,项目名称:ColorHighlighter,代码行数:8,代码来源:test_path.py


示例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)
开发者ID:DavidPesta,项目名称:ColorHighlighter,代码行数:8,代码来源:test_path.py


示例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()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:8,代码来源:test_windowmanager.py


示例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)
开发者ID:DavidPesta,项目名称:ColorHighlighter,代码行数:8,代码来源:test_settings.py


示例16: test_parse_complex_capabilities_string

 def test_parse_complex_capabilities_string(self):
     ctx = mock()
     bm = BrowserManagementKeywords(ctx)
     expected_caps = "proxyType:manual,httpProxy:IP:port"
     capabilities = bm._parse_capabilities_string(expected_caps)
     self.assertTrue("manual", capabilities["proxyType"])
     self.assertTrue("IP:port", capabilities["httpProxy"])
     self.assertTrue(2, len(capabilities))
     unstub()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:9,代码来源:test_browsermanagement.py


示例17: testUnstubClassMethod

    def testUnstubClassMethod(self):
        original_method = Dog.waggle
        when(Dog).waggle().thenReturn('Nope!')

        unstub()

        rex = Dog()
        self.assertEqual('Wuff!', rex.waggle())
        self.assertEqual(original_method, Dog.waggle)
开发者ID:kaste,项目名称:mockito-python,代码行数:9,代码来源:instancemethods_test.py


示例18: test_window_id_is_web_element

 def test_window_id_is_web_element(self):
     manager = WindowManager()
     driver = mock()
     elem = mock()
     self.mock_window_info(driver, *[elem, '', '', ''])
     driver.current_window_handle = HANDLE
     info = manager._get_current_window_info(driver)
     self.assertEqual(info[1], elem)
     unstub()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:9,代码来源:test_windowmananger_window_info.py


示例19: test_st3

 def test_st3(self):
     """In ST3 get_binary_resource_size just calls sublime.load_binary_resource."""
     when(st_helper).is_st3().thenReturn(True)
     test_path = "test/path"
     content = "content"
     when(sublime).load_binary_resource(test_path).thenReturn(content)
     self.assertEqual(len(content), get_binary_resource_size(test_path))
     verify(sublime).load_binary_resource(test_path)
     unstub(sublime)
开发者ID:DavidPesta,项目名称:ColorHighlighter,代码行数:9,代码来源:test_load_resource.py


示例20: test_open_browser_speed

 def test_open_browser_speed(self):
     ctx = mock()
     ctx.speed = 5.0
     browser = mock()
     when(webdriver).Chrome().thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     self.assertEqual(browser._speed, 5.0)
     unstub()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:9,代码来源:test_browsermanagement.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mockito.verify函数代码示例发布时间:2022-05-27
下一篇:
Python mockito.mock函数代码示例发布时间: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