Skip to content

Commit

Permalink
Explaing usage of the layer with Zope 2/3 in the documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
florianpilz committed Sep 30, 2016
1 parent 4763925 commit 93ebe57
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/narrative.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,24 @@ Example when using the layer:
... def make_wsgi_app(self):
... return zope.testbrowser.wsgi.AuthorizationMiddleware(simple_app)

There is also a BrowserLayer in `zope.app.wsgi.testlayer`_ which does this
There is also a ``BrowserLayer`` in `zope.app.wsgi.testlayer`_ which does this
for you and includes a ``TransactionMiddleware``, too, which could be handy
when testing a ZODB based application.

However, since the ``BrowserLayer`` in `zope.app.wsgi.testlayer`_ re-creates
the ZODB in ``testSetUp``, we need to re-create the WSGI App during
``testSetUp``, too. Therefore use ``TestBrowserLayer`` of
``zope.testbrowser.wsgi`` instead of the simpler ``Layer`` to combine it with
the ``BrowserLayer`` in `zope.app.wsgi.testlayer`_:

.. doctest::

>>> import zope.testbrowser.wsgi
>>> import zope.app.wsgi.testlayer
>>> class Layer(zope.testbrowser.wsgi.TestBrowserLayer,
... zope.app.wsgi.testlayer.BrowserLayer):
... pass

.. _`zope.app.wsgi.testlayer` : http://pypi.python.org/pypi/zope.app.wsgi
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ commands =
deps =
Sphinx
repoze.sphinx.autointerface
zope.app.wsgi

[testenv:flake8]
basepython = python2
Expand Down

0 comments on commit 93ebe57

Please sign in to comment.