Search the web
Sign In
New User? Sign Up
zope
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[Zope-dev] test setup layer sorting   Message List  
Reply | Forward Message #184168 of 185479 |
Re: [Zope-dev] test setup layer sorting

On Mon, Jul 13, 2009 at 12:27:50PM +0000, Reinout van Rees wrote:
> On 2009-07-13, Marius Gedminas <marius@...> wrote:
> >
> > Whatever grok does that interferes with coverage should be fixed.
>
> I did some more debugging. In the end it boils down to this:
>
> With z3c.testsetup, you can specify a zcml file at the top of your
> test file. z3c.testsetup creates a ZCMLLayer with that zcml file.
>
> I my test files, I had two separate zcml files (one registered a bit
> more than the other). So I ended up with two separate ZCMLLayer
> subclasses. And both did some grokking. So apparently the teardown
> of a ZCMLLayer subclass when going from one to the next isn't that
> clean. There *is* a warning in zope.testing that teardown isn't fully
> supported.

Ah, that one.

zope.testing supports test layers that muck up the global state
irrepairably (by letting the layer's tearDown method raise
NotImplementedError) and continues running the subsequent test layers in
a fresh and squeaky-clean subprocess.

Unfortunately, a separate process means separate coverage data tracking,
and currently zope.testing doesn't support merging coverage data from
several processes.

Fortunately, the NotImplementedError in ZCMLLayer's tearDown is just a
precaution, 99% of the time it is sufficient to run CleanUp.tearDown
to get the global state restored to its pristine condition. You can
indicate that it is safe by passing allow_teardown=True to ZCMLLayer's
constructor. As a result:

* the tests will run marginally faster (no subprocess overhead)

* you will be able to use pdb in your tests (zope.testing disables pdb
in a subprocess since it wants exclusive control over stdout)

* you will be able to get accurate coverage tracing.

Now, how you can convince z3c.testsetup to pass allow_teardown=True to
the ZCMLLayer it constructs, I don't know. I've never used
z3c.testsetup (although it sounds like an interesting library and I
should check it out some day).

ZCMLLayer's allow_teardown=True badly needs more publicity. Or maybe a
ruthless dictator, decreeing that it shall be on by default from some
near-future date.

> How I solved it: just use one zcml layer in z3c.testsetup and do some
> extra grokking in the test itself instead of in the second zcml file.

That will work until you decide to introduce a new layer.

Marius Gedminas
--
http://pov.lt/ -- Zope 3 consulting and development


Mon Jul 13, 2009 7:36 pm

marius@...
Send Email Send Email

Attachment
signature.asc
Type:
application/pgp-signature
_______________________________________________
Zope-Dev maillist - Zope-Dev@...
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Forward
Message #184168 of 185479 |
Expand Messages Author Sort by Date

zope/testing/testrunner/runner.py's order_by_bases() function orders layers by inheritance, basically. So if you've got a FunctionalTestLayer that inherits...
Reinout van Rees
reinout@...
Send Email
Jul 13, 2009
9:28 am

... Whatever grok does that interferes with coverage should be fixed. ... Personally I would much prefer for the unit test layer to be sorted first. It is...
Marius Gedminas
marius@...
Send Email
Jul 13, 2009
10:00 am

... +1 -- Benji York Senior Software Engineer Zope Corporation _______________________________________________ Zope-Dev maillist - Zope-Dev@... ...
Benji York
benji@...
Send Email
Jul 13, 2009
1:09 pm

... I did some more debugging. In the end it boils down to this: With z3c.testsetup, you can specify a zcml file at the top of your test file. z3c.testsetup...
Reinout van Rees
reinout@...
Send Email
Jul 13, 2009
12:28 pm

... Ah, that one. zope.testing supports test layers that muck up the global state irrepairably (by letting the layer's tearDown method raise ...
Marius Gedminas
marius@...
Send Email
Jul 13, 2009
7:36 pm

... Keep in mind that a number of commonly-used ZCML directives stamp interfaces on classes; these aren't cleaned up with the general tear-down. If each layer...
Fred Drake
fdrake@...
Send Email
Jul 13, 2009
8:52 pm

... Thanks a lot, now I finally understand the cause of the problem I've been seeing. It is OK to figure out *when* something goes wrong, but the *why* is ...
Reinout van Rees
reinout@...
Send Email
Jul 14, 2009
3:51 pm

... z3c.testsetup is great as it cuts down on the amount of repeated test setup code. (iirc stuff like nose and py.test also try this). Uli (=z3c.testsetup...
Reinout van Rees
reinout@...
Send Email
Jul 14, 2009
3:55 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help