Testing Zen

Here’s what I did for getting a nice testing frontend into Zope 2.

  1. Copy test.py from Zope 3 into INSTANCE_HOME.

  2. Copy framework.py from ZopeTestCase into INSTANCE_HOME.

  3. Add the following to test.py:

    if __name__ == '__main__':
       execfile(os.path.join(sys.path[0], 'framework.py'))
    
  4. Add the following to framework.py, just after import
    Testing
    :

    import Zope
    

Now, you can run the unittests using test.py and all the
facilities that you get from it. As an example, here’s what I have in
the makefile of one of my products:

SOFTWARE_HOME=~/src/zope/2_7/lib/python
INSTANCE_HOME=~/src/instance/shellex
PYTHON="/usr/bin/python"

test_all :

        export INSTANCE_HOME=${INSTANCE_HOME}; \
        export SOFTWARE_HOME=${SOFTWARE_HOME}; \
        cd ${INSTANCE_HOME} && ${PYTHON} test.py --all -vpT \
        --libdir=Products 'CMFMember|Calendaring|PluggableDiscussion'

Here, -v is for verbose, -p is for showing progress,
-T is for generating trace module stats. Refer to the source of
test.py for more command line options. The nice thing here, IMHO,
is to be able to specify a regular expression for matching modules
which tests should be run, and of course, the progress line is simply
amazing :)

Advertisement

2 thoughts on “Testing Zen

  1. Zope 3 test harness *good*
    I’ve been using the zope3 test harness in Roundup’s (http://roundup.sf.net/) latest development cycle which has been about 6 months. I needed to tweak a couple of zope-specific things out of the code, but otherwise it’s been so great to be able to narrow down the tests that are run, and run coverage analysis on them. And the GC testing is a boon too, especially with some third-party modules that leave garbage if you don’t treat them *just so*.

  2. interesting
    I am using::

    test:
    PYTHONPATH=/zope/lib/python SOFTWARE_HOME=/zope/lib/python INSTANCE_HOME=/zope1 \
    python /zope/test.py –libdir .

    /zope is SOFTWARE_HOME. Zope 2.7’s test.py seems zope 3-like.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.