Chris Withers wrote:
Hi All,

It would appear that Philipp's article is somewhat misleading in that layers can't be new style classes...

class MyLayer(object):

   def setUp(self): pass

   def tearDown(self): pass

..results in the following when used as a layer:

AttributeError: type object 'object' has no attribute 'setUp'

Is this a bug in Philipp's article or in the testrunner?

In Philipp's article.

Note that test layers don't have to be classes.  Classes
with class methods just happen to be a (seductively) convenient
implementation.  For example, ZCMLLayer defined in
is not a class, in the sense that Layer instances are not classes.

A layer is simply an object that has __module__, __name__, and __bases__
attributes and that has setUp and tearDown methods.  That's it.  You
can achieve that any way you want.  I regret the use of the __bases__
attribute.  It would have been better if I had left it up to layer
implementations to call base layers, rather than having the test runner call
them automatically.  It was a bad automation tradeoff.


Jim Fulton           mailto:[EMAIL PROTECTED]       Python Powered!
CTO                  (540) 361-1714  
Zope Corporation
Zope3-dev mailing list

Reply via email to