[Zope3-Users] Re: testing setup

Darryl Cousins darryl at darrylcousins.net.nz
Wed Jul 19 20:58:23 EDT 2006


Hi Luis,

You need to run functional tests using the zope testing environment
which is set up for you when the tests are run with $instance/bin/test

Functional tests are defined in python file ftests.py or package ftests/
which you will create in your package.

For example:

ftests.py::

import unittest
from zope.testing import doctest
from zope.app.testing.functional import FunctionalDocFileSuite


def test_suite():
    return unittest.TestSuite((
        FunctionalDocFileSuite(
            "README.txt",
            optionflags=doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE),
        ))

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')

And then README.txt::

  >>> from zope.testbrowser.testing import Browser 
  >>> browser = Browser(’http://localhost’) 
  >>> browser.url 
  ’http://localhost’ 
  >>> browser.contents 
  ’...<title>Z3: </title>...’


Have a look at: http://zope-cookbook.org/cookbook/recipe07#x1-6000
And
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/ftests.html#x1-800043.3

And have a read of zope/testbrowser/README.txt

There are other examples of tests in the source. Good luck.

Regards,
Darryl

luis wrote:

...

> ###
> from zope.testbrowser.testing import Browser
> 
> browser = Browser('http://localhost') 
> ###
> 
> just to see if I can open a connection to the "test server"... but if
> I try
> to run that code, I get this error message: 



More information about the Zope3-users mailing list