本文整理汇总了Python中Testing.testbrowser.Browser.handleErrors方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.handleErrors方法的具体用法?Python Browser.handleErrors怎么用?Python Browser.handleErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Testing.testbrowser.Browser
的用法示例。
在下文中一共展示了Browser.handleErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handle_errors_false_redirect
# 需要导入模块: from Testing.testbrowser import Browser [as 别名]
# 或者: from Testing.testbrowser.Browser import handleErrors [as 别名]
def test_handle_errors_false_redirect(self):
self.folder._setObject('redirect', RedirectStub())
browser = Browser()
browser.handleErrors = False
with self.assertRaises(NotFound):
browser.open('http://localhost/test_folder_1_/redirect')
self.assertTrue(browser.contents is None)
示例2: test_handle_errors_false
# 需要导入模块: from Testing.testbrowser import Browser [as 别名]
# 或者: from Testing.testbrowser.Browser import handleErrors [as 别名]
def test_handle_errors_false(self):
self.folder._setObject('stub', ExceptionStub())
browser = Browser()
browser.handleErrors = False
# Even errors which can be handled by Zope go to the client:
with self.assertRaises(NotFound):
browser.open('http://localhost/nothing-is-here')
self.assertTrue(browser.contents is None)
示例3: test_handle_errors_false_HTTPExceptionHandler_in_app
# 需要导入模块: from Testing.testbrowser import Browser [as 别名]
# 或者: from Testing.testbrowser.Browser import handleErrors [as 别名]
def test_handle_errors_false_HTTPExceptionHandler_in_app(self):
"""HTTPExceptionHandler does not handle errors if requested via WSGI.
This is needed when HTTPExceptionHandler is part of the WSGI pipeline.
"""
class WSGITestAppWithHTTPExceptionHandler(object):
"""Minimized testbrowser.WSGITestApp with HTTPExceptionHandler."""
def __call__(self, environ, start_response):
publish = HTTPExceptionHandler(publish_module)
wsgi_result = publish(environ, start_response)
return wsgi_result
self.folder._setObject('stub', ExceptionStub())
transaction.commit()
browser = Browser(wsgi_app=WSGITestAppWithHTTPExceptionHandler())
browser.handleErrors = False
with self.assertRaises(ValueError):
browser.open('http://localhost/test_folder_1_/stub')
self.assertIsNone(browser.contents)
示例4: testSkinSwitchUsingFallbackForm
# 需要导入模块: from Testing.testbrowser import Browser [as 别名]
# 或者: from Testing.testbrowser.Browser import handleErrors [as 别名]
def testSkinSwitchUsingFallbackForm(self):
self.loginAsPortalOwner()
folder_url = self.folder.absolute_url()
portal_url = self.portal.absolute_url()
# Add a second folder:
self.portal.invokeFactory('Folder', id='folder2')
folder2 = self.portal.folder2
wf_tool = getToolByName(self.portal, 'portal_workflow')
wf_tool.doActionFor(folder2, 'publish')
folder2_url = folder2.absolute_url()
# Add a sub folder:
folder2.invokeFactory('Folder', id='sub_folder')
sub_folder = folder2.sub_folder
wf_tool.doActionFor(sub_folder, 'publish')
sub_folder_url = sub_folder.absolute_url()
# Create a new default skin.
new_default_skin(self.portal)
# Set the default skin for the first folder.
browser = Browser()
browser.handleErrors = False
self._login(browser)
browser.open(folder_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual([], control.value)
control.value = ["Monty Python Skin"]
# Saving the form redirects back to the folder.
browser.getControl(name="form.button.Save").click()
self.assertEqual(folder_url, browser.url)
# Going back to the form has the skin selected.
browser.open(folder_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual(["Monty Python Skin"], control.value)
# Set the default skin for the second folder. We have to do
# this as portal owner.
self._login(browser, login_name=ptc.portal_owner)
browser.open(folder2_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual([], control.value)
control.value = ["Sunburst Theme"]
browser.getControl(name="form.button.Save").click()
browser.open(folder2_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual(["Sunburst Theme"], control.value)
# Set a different default skin for the sub folder.
browser.open(sub_folder_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual([], control.value)
control.value = ["Monty Python Skin"]
browser.getControl(name="form.button.Save").click()
browser.open(sub_folder_url + "/select_skin")
control = browser.getControl(name="skin_name")
self.assertEqual(["Monty Python Skin"], control.value)
# What is the current skin name in a few contexts?
self._login(browser)
browser.open(portal_url + '/getCurrentSkinName')
self.assertEqual(browser.contents, 'Monty Python Skin')
browser.open(folder_url + '/getCurrentSkinName')
self.assertEqual(browser.contents, 'Monty Python Skin')
browser.open(folder2_url + '/getCurrentSkinName')
self.assertEqual(browser.contents, 'Sunburst Theme')
browser.open(sub_folder_url + '/getCurrentSkinName')
self.assertEqual(browser.contents, 'Monty Python Skin')
# Check the effect this has when visiting these contexts. We
# do this with an almost empty browser view that shows a
# viewlet that is specifically registered for the Monty Python
# theme and not the Sunburst Theme theme. Plus a viewlet that
# shows which marker interfaces the request provides.
# First the portal root:
browser.open(portal_url + '/@@viewlet-test')
self.assertTrue('We want a shrubbery!' in browser.contents)
self.assertTrue('interfaces.IMyTheme' in browser.contents)
# Then the first folder:
browser.open(folder_url + '/@@viewlet-test')
self.assertTrue('We want a shrubbery!' in browser.contents)
self.assertTrue('interfaces.IMyTheme' in browser.contents)
# Then the second folder:
browser.open(folder2_url + '/@@viewlet-test')
self.assertFalse('We want a shrubbery!' in browser.contents)
self.assertFalse('interfaces.IMyTheme' in browser.contents)
# Then the sub folder:
browser.open(sub_folder_url + '/@@viewlet-test')
self.assertTrue('We want a shrubbery!' in browser.contents)
self.assertTrue('interfaces.IMyTheme' in browser.contents)