[Zope-CMF] unit test weirdness.

Mark McEahern marklists@mceahern.com
Wed, 19 Feb 2003 16:15:45 -0600

[Dieter Maurer]
> Maybe, "testrunner" magically extends PYTHONPATH depending on the
> target.
> If this is the case, set up PYTHONPATH as necessary, before you
> run "testrunner".

I don't think that's the problem.  I've seen same behavior, fwiw...

When I run:

  utilities/testrunner.py -d ./lib/python/Products

the tests run fine.  But when I try to run specific tests--e.g.,

  utilities/testrunner.py -d ./lib/python/Products/CMFCore

they fail with import errors.  I don't think it has to do with PYTHONPATH.
Notice in the output appended below that testrunner.py adds the same path to
sys.path regardless of the value specified for -d.

I think the problem is that the earlier tests are importing something that
the latter tests depend on.  (import ZODB?  Naively adding that to my own
tests, sadly, doesn't fix the problem.) That's why, I speculate, running all
tests works but trying to run a more focused set of tests (e.g., CMFCore)

// m

$ sudo python2.1 utilities/testrunner.py -d ./lib/python/Products
Adding /usr/local/Zope-2.6.1-src/lib/python to sys.path.
testStorage (testExternalMethod.Test) ... ok
test_mapply (testExternalMethod.Test) ... ok

$ sudo python2.1 utilities/testrunner.py -d ./lib/python/Products/CMFCore
Adding /usr/local/Zope-2.6.1-src/lib/python to sys.path.
Module test_ActionInformation.py failed to load
exceptions.ImportError: cannot import name Persistent
  File "utilities/testrunner.py", line 60, in getSuiteFromFile
   File "test_ActionInformation.py", line 4, in ?
    from Products.CMFCore.tests.base.testcase import \
   File "/usr/local/zope/lib/python/Products/CMFCore/__init__.py", line 18,
in ?
    import PortalObject, PortalContent, PortalFolder
   File "/usr/local/zope/lib/python/Products/CMFCore/PortalObject.py", line
18, in ?
    from Globals import InitializeClass
   File "/var/tmp/src/Zope-2.6.1-src/lib/python/Globals.py", line 23, in ?
    import Acquisition, ComputedAttribute, App.PersistentExtra, os
   File "/var/tmp/src/Zope-2.6.1-src/lib/python/App/PersistentExtra.py",
line 15, in ?
    from Persistence import Persistent