[Zope-CMF] unit testing evil

Tres Seaver tseaver@zope.com
Thu, 10 Jan 2002 15:19:52 -0500


seb bacon wrote:

> I'm working at different location from usual.  I somehow managed to get
> the run_all_tests script to work on my other computer, to which I have
> no access for a while.  I now have no idea how I acheived that.
> 
> Could we have a definitive answer: how do the ZC 'malcontents' run unit
> tests?  Do you use run_all_tests?  A post from Tres in November seemed
> to suggest you favour testrunner.py, but I'm getting baffled by
> PYTHONPATH problems ('Could not import ZServer').
> 
> This is stopping me contributing a fix to CMFCollector, so any help
> would result in Good Things :-)

Here is the script I use::


  #! /bin/sh
  #
  # Run all CMF unit tests.
  #
  ZOPE_HOME=/usr/local/zope/Zope-2.4-head
  SOFTWARE_HOME=$ZOPE_HOME/lib/python
  INSTANCE_HOME=`pwd`
  PYTHONPATH=$SOFTWARE_HOME
  export ZOPE_HOME SOFTWARE_HOME INSTANCE_HOME PYTHONPATH
  #
  #   You can skip setting these if you don't run using ZEO.
  #
  ZEO_SERVER_NAME=localhost
  ZEO_SERVER_PORT=9001
  export ZEO_SERVER_NAME ZEO_SERVER_PORT
  /usr/local/bin/python2.1 $INSTANCE_HOME/CMF-head/all_cmf_tests.py


It currently produces the following output::

  $ ./run_unit_tests
  ......................................................................\
  ......................................................................\
  .................
  ----------------------------------------------------------------------
  Ran 157 tests in 6.648s

  OK

I think I recall the "can't import ZServer" error you note as
a ZEO bug;  the fix is either to include $ZOPE_HOME in $PYTHONPATH
or to symlink $ZOPE_HOME/ZServer into $ZOPE_HOME/lib/python (I
normally do the latter when setting up a new Zope sandbox).

BTW, CMFCollector currently has no tests (at least, not on the
head);  are you planning to add some?  Also, I don't think that
'all_cmf_tests.py' currently includes CMFCollector's 'test_all',
as it has been empty.


-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com