Finally following up... Thanks for the clarification. For anybody else puzzling over how to use layers, there are a couple details that weren't obvious to me from the docs. I wrote them up here:
http://zopewiki.org/TestLayersHowTo and a front page at http://zopewiki.org/TestLayers -PW On Mon, Jul 10, 2006 at 09:51:03PM +0200, Philipp von Weitershausen wrote: > Paul Winkler wrote: > > I have a need to have a batch of tests that do some expensive > > setup once for the whole batch. AFAICT this is what layers are for. > > Indeed. > > > One question though... Why do the examples in > > zope/testing/testrunner-ex/samplelayers.py have setUp() and tearDown() > > as classmethods? > > Because the test runner expects layers to be objects with setUp() and > tearDown() "methods". So, if you want to pass a class without > instantiating it first, you need to make these class methods so that > they don't expect 'self' as the first argument. > > > Is it just an implementation detail of those tests, or something > > I should be aware of when creating my own layers? > > Just pass in any object that has 'setUp' and 'tearDown' callables as > attributes :). Well, no, it also needs __bases__ and __name__ attributes, as I discovered. So a vanilla class instance won't work unless you provide those at least. I don't know if there are other constraints with using instances, I didn't investigate further. It also cannot be a new-style class, as the test runner expects *all* base classes to have a setUp() method, and object does not. An old-style class with classmethods is really the most convenient thing. -- Paul Winkler http://www.slinkp.com _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users