[TIP] Hi, beginner nose question
fdrake at gmail.com
Wed Nov 21 18:25:44 PST 2007
On Nov 20, 2007 5:10 AM, iain duncan <iainduncan at telus.net> wrote:
> What if, for functional or integration tests, I want to run some fixture
> house keeping once *per* class, before and after all that classes tests?
The zope.testing test runner provides the ability to define "layers",
which can have explicit setup and teardown. This divorces the setup
and teardown from any particular Python language structure; tests can
be associated with whatever layer makes sense. This is commonly used
for functional testing, with unit test having no layer.
Layers are hierarchical, so shared initialization can really be
shared; this can be helpful when fixture initialization is expensive.
Another interesting aspect of the zope.testing layers is that the
teardown is optional; if the layer cannot be torn down, further tests
are automatically run in a new process. (It's not unusual for Zope
functional tests to affect a lot of global state, such as annotations
getting scribbled on classes, so we use layers that can't be torn down
Fred L. Drake, Jr. <fdrake at gmail.com>
"Chaos is the score upon which reality is written." --Henry Miller
More information about the testing-in-python