[Zope3-dev] layers can't be new style classes?

Paul Winkler pw_lists at slinkp.com
Tue Oct 17 10:58:45 EDT 2006


On Tue, Oct 17, 2006 at 11:30:46AM +0100, 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?

I noticed the same thing when I wrote my zopewiki page
(http://zopewiki.org/TestLayersHowTo)
but it looks like new-style classes should work now,
judging by this svn log message:

"""
r68925 | Zen | 2006-06-30 07:49:37 -0400 (Fri, 30 Jun 2006) | 3 lines

Fix ordering of testSetUp and testTearDown calls, and allow new style
classes
to be used as Layers by explicitly ignoring the object baseclass.
"""

Also, at the time I wrote that page (in July), I wasn't aware of
zope/testing/testrunner-layers-api.txt
which would've saved me some trial and error.
That may be the narrative you're looking for?
I'll update the zopewiki page with a reference to that doc.

Looks like that file is shipped with Zope 2.10.0 and 2.9.5,
but it wasn't in 2.9.4.  I haven't been living on the bleeding
edge lately so I didn't see it.

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope3-dev mailing list