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

2006-10-17 Thread Stefan H. Holek

IIRC you need

@classmethod
def setUp(cls):
pass

@classmethod
def tearDown(cls):
pass


On 17. Okt 2006, at 12:30, Chris Withers wrote:

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?


--
Anything that, in happening, causes something else to happen,
causes something else to happen.  --Douglas Adams


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Chris Withers

Stefan H. Holek wrote:

IIRC you need

@classmethod
def setUp(cls):
pass

@classmethod
def tearDown(cls):
pass


Sorry, braino on my part. Yes, I have the @classmethod's and I still see 
the error:



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


cheers,

Chris

PS: Has anyone doen the work Philipp aludes to in his article to make 
ZopeTestCase a series of layers?


--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Jim Fulton

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 zope.app.testing.functional
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

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Chris Withers

Jim Fulton wrote:

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.


Is it too late to add an explicit Layer class to zope.testing that deals 
with this properly rather than confusing n00bs like me?


(even if it does involve some BBB if/then/else'ing in testrunner.py...)

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Jim Fulton

Jim Fulton wrote:

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.


I may have spoken too soon.  It looks like there is code to
handle the object-as-base case in the test runner, at least on the trunk.
Perhaps the version used by zope3 doesn't handle this case, or
perhaps there's a bug that needs to be pursued.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Chris Withers

Jim Fulton wrote:

I may have spoken too soon.  It looks like there is code to
handle the object-as-base case in the test runner, at least on the trunk.
Perhaps the version used by zope3 doesn't handle this case, or
perhaps there's a bug that needs to be pursued.


That'd explain it, I'm using 2.9.4 ;-)

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Paul Winkler
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
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2006-10-17 Thread Chris Withers

Paul Winkler wrote:

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.



Yes indeed...


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.


Yup, the narrative I was missing is here:
http://svn.zope.org/zope.testing/trunk/src/zope/testing/testrunner-layers-api.txt?rev=70271view=auto

I guess it's time for me to move to a newer zope.testing ;-)

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com