ZCML is set up using test layers. Their setUp() and tearDown() methods
are only run once for all tests in the layer.
Maybe of interest, I've attached the layers file I use when testing Zope
2 apps. It "does the right thing" w.r.t. having a DemoStorage for each
layer, letting you safely commit transactions containing layer setup and
then using the using transaction.begin()/transaction.abort() dance in
the tests themselves.
Is this code useful? Should I look to check it in to the core anywhere?
For functional tests that depend on a complete CMF site, you can use the
FunctionalLayers defined in the testing modules. They have to be used
with ZopeTestCase's FunctionalTestCase
Hmmm, which version of Zope did this arrive in?
Finally, a question of my own, how do you use layers with doctests?
Simplistix - Content Management, Zope & Python Consulting
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
# this import, rather evilly, causes Zope2.bobo_application and Zope2.DB
# to come into existence :-(
from Testing.ZopeTestCase import ZopeLite
from Testing.ZopeTestCase.utils import makerequest
from ZODB import DB
from ZODB.DemoStorage import DemoStorage
state = [Zope2.DB]
# Zope 2 chickens
Globals.BobobaseName = db.getName()
Globals.DB = db
Zope2.DB = db
ZopeLite.DB = db
junk_db, name, version_support = Zope2.bobo_application._stuff
Zope2.bobo_application._stuff = db, name, version_support
previous = state[-1]
storage = DemoStorage(base=previous._storage)
db = DB(storage)
db.classFactory = previous.classFactory
# cluck cluck
db = state.pop()
# commit changes
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests