[Zope-dev] test setup layer sorting

Reinout van Rees reinout at vanrees.org
Tue Jul 14 11:54:27 EDT 2009


On 2009-07-13, Marius Gedminas <marius at gedmin.as> wrote:
>
> 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=3DTrue 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=3DTrue 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).

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 author), what about changing z3c.testsetup's default in
this regard?


Reinout

-- 
Reinout van Rees - reinout at vanrees.org - http://reinout.vanrees.org
Software developer at http://www.thehealthagency.com
"Military engineers build missiles. Civil engineers build targets"



More information about the Zope-Dev mailing list