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

2006-10-17 Thread Chris Withers
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

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

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'

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

2006-10-17 Thread Jürgen Kartnaller
Hi Chris. Look at z3c.sampledata.layer, I provide a testlayer there. Maybe you need to provide the __bases__! Jürgen 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

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Martin Aspeli
Chris Withers wrote: Now, related to this, say I have content objects X and Y, which are expensive to set up. I have LayerX which sets up a sample content object X, and LayerY which does the same for content object Y. This is fine for tests which need one or other content type, but how

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Jim Fulton
Chris Withers wrote: Hi All, Am I right in assuming that there aren't any good narrative docs for test layers? This is obviously in the eye of the beholder. I'm sure the people who created narratives tried to do a good job. Perhaps you can do better. ... Now, related to this, say I have

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Chris Withers
Martin Aspeli wrote: Layers are ... layered. If your test base class has layer X and a test case subclass of that has layer Y, then it will set up X, run all the X tests, then setup Y and run all the Y and XY tests, then tear down Y and then X. I didn't mention subclassing tests. Personally,

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

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Chris Withers
Jim Fulton wrote: Am I right in assuming that there aren't any good narrative docs for test layers? This is obviously in the eye of the beholder. I'm sure the people who created narratives tried to do a good job. Perhaps you can do better. I may be missing some then... which narratives are

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

[Zope3-dev] another layers quicky?

2006-10-17 Thread Chris Withers
Hi (yet) again ;-) class MyLayer: @classmethod def setUp(self): self.app = Testing.ZopeTestCase.Zope2.app() @classmethod def tearDown(self): Testing.ZopeTestCase.close() class MyTests(TestCase): def setUp(self): self.savepoint = transaction.savepoint() self.app =

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:

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Jim Fulton
Chris Withers wrote: Jim Fulton wrote: Am I right in assuming that there aren't any good narrative docs for test layers? This is obviously in the eye of the beholder. I'm sure the people who created narratives tried to do a good job. Perhaps you can do better. I may be missing some then...

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

Re: [Zope3-dev] Test Layers

2006-10-17 Thread Chris Withers
Jim Fulton wrote: I may be missing some then... which narratives are you thinking of? You cited 3 in your note. I'd like there to be a good narrative that actually ships in zope.testing, I'm willing to do the work to make that happen provided I can get some help on writing the doctest of

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

2006-10-17 Thread Chris Withers
whit wrote: there is also a version of ztc by layers for 2.9(see zope2 branches) Which branch exactly? I'm using 2.9.4 and can't see any evidence of layers... Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk

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

2006-10-17 Thread whit
Chris Withers wrote: 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

[Zope3-dev] testing and savepoints

2006-10-17 Thread Chris Withers
Hi all, (sorry if some of this is Zope 2 - ish, the thread kinda started here and the underlying bits of this are certainly relevant to Zope 3) As you may have guessed by the flurry of mails today, I've been refactoring a 2000 test suite to use layers. I was hoping to use savepoints to

[Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Philipp von Weitershausen
Chris Withers wrote: Hi (yet) again ;-) class MyLayer: @classmethod def setUp(self): self.app = Testing.ZopeTestCase.Zope2.app() @classmethod def tearDown(self): Testing.ZopeTestCase.close() Shrug! That will modify the class! self is the class here (it's convention to call

Re: [Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Chris Withers
Philipp von Weitershausen wrote: What do I put in place of the ? to get hold of the layer's app? self.layer.app but self.layer is a string, no? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk

Re: [Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Chris Withers
Philipp von Weitershausen wrote: Chris Withers wrote: Philipp von Weitershausen wrote: What do I put in place of the ? to get hold of the layer's app? self.layer.app but self.layer is a string, no? Huh? No, it's the layer object (e.g. the class) even if you do: class

Re: [Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Philipp von Weitershausen
Chris Withers wrote: Philipp von Weitershausen wrote: Chris Withers wrote: Philipp von Weitershausen wrote: What do I put in place of the ? to get hold of the layer's app? self.layer.app but self.layer is a string, no? Huh? No, it's the layer object (e.g. the class) even if you do:

Re: [Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Chris Withers
Philipp von Weitershausen wrote: ? No. Who said you should do that? http://zopewiki.org/TestLayersHowTo Will a string even work? Yes. Chris - anyway, right now I'm more annoyed that savepoints are sllooo and DemoStorage doesn't support undo... help with either would be much

Re: [Zope3-dev] Re: another layers quicky?

2006-10-17 Thread Paul Winkler
On Tue, Oct 17, 2006 at 05:40:51PM +0100, Chris Withers wrote: Philipp von Weitershausen wrote: ? No. Who said you should do that? http://zopewiki.org/TestLayersHowTo ... and more authoritatively, a number of tests in zope/testing/testrunner-ex use strings. Prior to the introduction of

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

[Zope3-dev] Re: testing and savepoints

2006-10-17 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris Withers wrote: Hi all, (sorry if some of this is Zope 2 - ish, the thread kinda started here and the underlying bits of this are certainly relevant to Zope 3) As you may have guessed by the flurry of mails today, I've been refactoring a

Re: [Zope3-dev] testing and savepoints

2006-10-17 Thread Gary Poster
On Oct 17, 2006, at 12:01 PM, Chris Withers wrote: So I'm left what the actual use for savepoints is 1) you want to reduce your memory usage within a transaction 2) a) sometimes you want to roll back to a certain point in a transaction. b) sometimes you do this in a context of an

Re: [Zope3-dev] testing and savepoints

2006-10-17 Thread Chris Withers
Jim Fulton wrote: Each layer drops a savepoint in setUp and then rolls it back it in tearDown. Likewise, the TestCase's setUp would drop a savepoint and the tearDown would roll back to it. This is a risky approach. If you have any software that does actual commits, you'll be hosed. Not

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

Re: [Zope3-dev] testing and savepoints

2006-10-17 Thread Jim Fulton
Chris Withers wrote: Jim Fulton wrote: Each layer drops a savepoint in setUp and then rolls it back it in tearDown. Likewise, the TestCase's setUp would drop a savepoint and the tearDown would roll back to it. This is a risky approach. If you have any software that does actual commits,

Re: [Zope3-dev] testing and savepoints

2006-10-17 Thread Chris Withers
Jim Fulton wrote: You do realize that you can stack demo storages. Would I be torturing myself like this if I did? ;-) Create a demo storage for the layer and test and toss the database when you're done. Look at the way zope.app.testing.functional works for an example. Yay! Thankyou :-)

Re: [Zope3-dev] testing and savepoints

2006-10-17 Thread Stephan Richter
On Tuesday 17 October 2006 14:47, Jim Fulton wrote: You do realize that you can stack demo storages. Create a demo storage for the layer and test and toss the database when you're done.  Look at the way zope.app.testing.functional works for an example. Yep, we utilize that functional setup