It is possible to inject a wsgi stack by subclassing from BrowserLayer::

First, create and register a view to test:

    >>> from zope import component, interface
    >>> from zope.app.wsgi.testing import IndexView
    >>> component.provideAdapter(IndexView, name='index.html')
    >>> from zope.security import checker
    >>> checker.defineChecker(
    ...     IndexView,
    ...     checker.NamesChecker(['browserDefault', '__call__']),
    ...     )
    >>> from zope.app.wsgi.testing import ErrorRaisingView
    >>> component.provideAdapter(ErrorRaisingView, name='error.html')
    >>> checker.defineChecker(
    ...     ErrorRaisingView,
    ...     checker.NamesChecker(['browserDefault', '__call__']),
    ...     )

The `silly middleware` has injected information into the page:

    >>> from zope.app.wsgi.testlayer import Browser
    >>> browser = Browser()
    >>> browser.open('http://localhost/index.html')
    >>> print browser.contents
    <html>
      <head>
      </head>
      <body><h1>Hello from the silly middleware</h1>
        <p>This is the index</p>
      </body>
    </html>

The default behavior of the browser is to handle errors::

    >>> browser.open('http://localhost/error.html')
    Traceback (most recent call last):
    ...
    HTTPError: HTTP Error 500: Internal Server Error

One can set error handling behavior::

    >>> browser.handleErrors = False
    >>> browser.open('http://localhost/error.html')
    Traceback (most recent call last):
    ...
    ZeroDivisionError: integer division or modulo by zero

The http caller is more low level than the Browser.
It exposes the same error handling parameter::

    >>> from zope.app.wsgi.testlayer import http
    >>> response = http('GET /error.html HTTP/1.1')
    >>> response.getStatus() == 500
    True
    >>> http('GET /error.html HTTP/1.1', handle_errors=False)
    Traceback (most recent call last):
    ...
    ZeroDivisionError: integer division or modulo by zero

Clean up:

    >>> import zope.publisher.interfaces.browser
    >>> checker.undefineChecker(IndexView)
    >>> component.provideAdapter(
    ...     None,
    ...     (interface.Interface,
    ...     zope.publisher.interfaces.browser.IBrowserRequest),
    ...     zope.publisher.interfaces.browser.IBrowserPublisher,
    ...     'index.html',
    ...     )
    >>> checker.undefineChecker(ErrorRaisingView)
    >>> component.provideAdapter(
    ...     None,
    ...     (interface.Interface,
    ...     zope.publisher.interfaces.browser.IBrowserRequest),
    ...     zope.publisher.interfaces.browser.IBrowserPublisher,
    ...     'error.html',
    ...     )
