[Checkins] SVN: zope.app.wsgi/branches/janjaapdriessen-webtest/src/zope/app/wsgi/testlayer.py Remove the error handling middleware as this already occurs in zope.testbrowser. Fix the http caller to use WebTest in zope.testbrowser.
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Tue Mar 15 18:36:16 EDT 2011
Log message for revision 120957:
Remove the error handling middleware as this already occurs in zope.testbrowser. Fix the http caller to use WebTest in zope.testbrowser.
Changed:
U zope.app.wsgi/branches/janjaapdriessen-webtest/src/zope/app/wsgi/testlayer.py
-=-
Modified: zope.app.wsgi/branches/janjaapdriessen-webtest/src/zope/app/wsgi/testlayer.py
===================================================================
--- zope.app.wsgi/branches/janjaapdriessen-webtest/src/zope/app/wsgi/testlayer.py 2011-03-15 22:34:58 UTC (rev 120956)
+++ zope.app.wsgi/branches/janjaapdriessen-webtest/src/zope/app/wsgi/testlayer.py 2011-03-15 22:36:15 UTC (rev 120957)
@@ -46,29 +46,6 @@
self.root_factory()._p_jar.sync()
-class HandleErrorsMiddleware(object):
- """This middleware makes the WSGI application compatible with the
- HTTPCaller behavior defined in zope.app.testing.functional:
- - It honors the X-zope-handle-errors header in order to support
- zope.testbrowser Browser handleErrors flag.
- """
-
- default_handle_errors = 'True'
-
- def __init__(self, app, wsgi_stack):
- self.app = app
- self.wsgi_stack = wsgi_stack
-
- def __call__(self, environ, start_response):
- # Handle debug mode
- handle_errors = environ.get(
- 'HTTP_X_ZOPE_HANDLE_ERRORS', self.default_handle_errors)
- self.app.handleErrors = handle_errors == 'True'
-
- for entry in self.wsgi_stack(environ, start_response):
- yield entry
-
-
class BrowserLayer(zope.testbrowser.wsgi.Layer, ZODBLayer):
"""This create a test layer with a test database and register a wsgi
application to use that test database.
@@ -89,11 +66,10 @@
# off of that in testSetUp()
fake_db = object()
self._application = WSGIPublisherApplication(fake_db)
- return zope.testbrowser.wsgi.AuthorizationMiddleware(HandleErrorsMiddleware(
- self._application,
+ return zope.testbrowser.wsgi.AuthorizationMiddleware(
TransactionMiddleware(
self.getRootFolder,
- self.setup_middleware(self._application))))
+ self.setup_middleware(self._application)))
def testSetUp(self):
super(BrowserLayer, self).testSetUp()
@@ -142,17 +118,12 @@
def http(string, handle_errors=True):
- # Existing tests fail without this. They are a bit sloppy and have
- # a leading \n which WebOb rejects.
- string = string.lstrip()
-
app = zope.testbrowser.wsgi.Layer.get_app()
if app is None:
raise NotInBrowserLayer(NotInBrowserLayer.__doc__)
request = TestRequest.from_file(StringIO(string))
- request.headers['X-zope-handle-errors'] = str(handle_errors)
-
+ request.environ['wsgi.handleErrors'] = handle_errors
response = request.get_response(app)
return FakeResponse(response)
More information about the checkins
mailing list