Related to the thread about how best to set up CMFTestCase...
I'm just wondering if I'm doing anything non-kosher by deriving
from both CMFTestCase and ZopeTestCase.Sandboxed, which
theoretically should prevent any ZODB-pollution as long as I don't
do the global CMF site setup.

It mostly seems to work, but as far as I can tell, you *must*
inherit in exactly that order, i.e.

class MyTest(ZopeTestCase.Sandboxed, CMFTestCase.CMFTestCase):

    def getPortal(self):
        return getattr(, CMFTestCase.portal_name)


The inheritance order should probably be documented somewhere.
If I switch the order, I get lots of barfing on getPortal() calls,
the getattr() fails.
.... Ahhh, I see; setupCMFSite() does its own call to  Hmm, could it take an optional app
argument? That would allow it to be used like so:

    def getPortal(self):
        return getattr(, CMFTestCase.portal_name)

The modified setup function could be like so:

def setupCMFSite(id=portal_name, quiet=0, app=None):
    '''Creates a CMF site.'''
    if app is None:
        app =
        close = ZopeTestCase.close
        # Don't clase the app if it already existed.
        def close(the_app):
    _setupCMFSite(app, id, quiet)

That seems to pass all tests with CMFTestCase,
and hey presto, my own product's tests work with it too and now the
inheritance order no longer seems to matter.

Thoughts? Stefan?

Paul Winkler

Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to