------------------
- Converted most doctests to Sphinx documentation, and published to
https://zopetestbrowser.readthedocs.io/ .
- Internal implementation now uses WebTest instead of ``mechanize``.
The ``mechanize`` dependency is completely dropped.
**This is a backwards-incompatible change.**
- Remove APIs:
- ``zope.testbrowser.testing.Browser`` (this is a big one).
Instead of using ``zope.testbrowser.testing.Browser()`` and relying on
it to magically pick up the ``zope.app.testing.functional`` singleton
application, you now have to define a test layer inheriting from
``zope.testbrowser.wsgi.Layer``, overrride the ``make_wsgi_app`` method
to create a WSGI application, and then use
``zope.testbrowser.wsgi.Browser()`` in your tests.
(Or you can set up a WSGI application yourself in whatever way you like
and pass it explicitly to
``zope.testbrowser.browser.Browser(wsgi_app=my_app)``.)
Example: if your test file looked like this ::
my/package/tests.py
from zope.app.testing.functional import defineLayer
from zope.app.testing.functional import FunctionalDocFileSuite
defineLayer('MyFtestLayer', 'ftesting.zcml', allow_teardown=True)
def test_suite():
suite = FunctionalDocFileSuite('test.txt', ...)
suite.layer = MyFtestLayer
return suite
now you'll have to use ::
my/package/tests.py
from unittest import TestSuite
import doctest
import zope.app.wsgi.testlayer
import zope.testbrowser.wsgi
class Layer(zope.testbrowser.wsgi.TestBrowserLayer,
zope.app.wsgi.testlayer.BrowserLayer):
"""Layer to prepare zope.testbrowser using the WSGI app."""
layer = Layer(my.package, 'ftesting.zcml', allowTearDown=True)
def test_suite():
suite = doctest.DocFileSuite('test.txt', ...)
suite.layer = layer
return suite
and then change all your tests from ::
>>> from zope.testbrowser.testing import Browser
to ::
>>> from zope.testbrowser.wsgi import Browser
Maybe the blog post `Getting rid of zope.app.testing`_ could help you adapting to this new version, too.
- Remove modules:
- ``zope.testbrowser.connection``
- Remove internal classes you were not supposed to use anyway:
- ``zope.testbrowser.testing.PublisherResponse``
- ``zope.testbrowser.testing.PublisherConnection``
- ``zope.testbrowser.testing.PublisherHTTPHandler``
- ``zope.testbrowser.testing.PublisherMechanizeBrowser``
- ``zope.testbrowser.wsgi.WSGIConnection``
- ``zope.testbrowser.wsgi.WSGIHTTPHandler``
- ``zope.testbrowser.wsgi.WSGIMechanizeBrowser``
- Remove internal attributes you were not supposed to use anyway (this
list is not necessarily complete):
- ``Browser._mech_browser``
- Remove setuptools extras:
- ``zope.testbrowser[zope-functional-testing]``
- Changed behavior:
- The testbrowser no longer follows HTML redirects aka
``<meta http-equiv="refresh" ... />``. This was a `mechanize` feature which
does not seem to be provided by `WebTest`.
- Add support for Python 3.3, 3.4 and 3.5.
- Drop support for Python 2.5 and 2.6.
- Drop the ``WebTest <= 1.3.4`` pin. We require ``WebTest >= 2.0.8`` now.
- Remove dependency on deprecated ``zope.app.testing``.
- Bugfix: ``browser.getLink()`` could fail if your HTML contained ``<a>``
elements with no href attribute
(https://github.com/zopefoundation/zope.testbrowser/pull/3).
.. _`Getting rid of zope.app.testing` : https://icemac15.wordpress.com/2010/07/10/appswordpressicemac20100710get-rid-of-zope-app-testing-dependency/