[Zope3-Users] Re: testrunner layers example and classmethods
Philipp von Weitershausen
philipp at weitershausen.de
Mon Jul 10 15:51:03 EDT 2006
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 :).
Philipp
More information about the Zope3-users
mailing list