Skip to content

Commit

Permalink
Initial attempt at replacing zope.testbrowser.wsgi with WebTest integ…
Browse files Browse the repository at this point in the history
…ration.
  • Loading branch information
Brian Sutherland committed Feb 2, 2011
1 parent 6f93762 commit 4834f1d
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 236 deletions.
24 changes: 9 additions & 15 deletions src/zope/testbrowser/README.txt
Expand Up @@ -21,18 +21,24 @@ WSGI Test Browser
~~~~~~~~~~~~~~~~~

There is also a special version of the ``Browser`` class which uses
`wsgi_intercept`_ and can be used to do functional testing of WSGI
`WebTest`_ and can be used to do functional testing of WSGI
applications, it can be imported from ``zope.testbrowser.wsgi``:

>>> from zope.testbrowser.wsgi import Browser as WSGIBrowser
>>> browser = WSGIBrowser()
>>> from wsgiref.simple_server import demo_app
>>> browser = WSGIBrowser('http://localhost/', wsgi_app=demo_app)
>>> print browser.contents
Hello world!
...

.. _`wsgi_intercept`: http://pypi.python.org/pypi/wsgi_intercept
.. _`WebTest`: http://pypi.python.org/pypi/WebTest

To use this browser you have to:

* use the `wsgi` extra of the ``zope.testbrowser`` egg,

You can also use it with zope layers by:

* write a subclass of ``zope.testbrowser.wsgi.Layer`` and override the
``make_wsgi_app`` method,

Expand All @@ -47,18 +53,6 @@ Example:

Where ``simple_app`` is the callable of your WSGI application.

Zope 3 Test Browser
~~~~~~~~~~~~~~~~~~~

WSGI applications can also be tested directly when wrapped by WebTest:

>>> from zope.testbrowser.webtest import Browser as WSGIBrowser
>>> from wsgiref.simple_server import demo_app
>>> browser = WSGIBrowser(demo_app, url='http://localhost/')
>>> print browser.contents
Hello world!
...

Bowser Usage
------------

Expand Down
7 changes: 4 additions & 3 deletions src/zope/testbrowser/tests/test_doctests.py
Expand Up @@ -16,11 +16,12 @@
import unittest

import zope.testbrowser.ftests.wsgitestapp
import zope.testbrowser.webtest
import zope.testbrowser.wsgi

def make_browser(*args, **kw):
app = zope.testbrowser.ftests.wsgitestapp.WSGITestApplication()
return zope.testbrowser.webtest.Browser(app, *args, **kw)
assert 'wsgi_app' not in kw
kw['wsgi_app'] = zope.testbrowser.ftests.wsgitestapp.WSGITestApplication()
return zope.testbrowser.wsgi.Browser(*args, **kw)

def test_suite():
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
Expand Down
147 changes: 0 additions & 147 deletions src/zope/testbrowser/webtest.py

This file was deleted.

0 comments on commit 4834f1d

Please sign in to comment.