Testrunner calls setUp/tearDown of super class when layers do not define setUp/tearDown themselves

Bug #544138 reported by Christian Zagrodnick
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zope.testing
Invalid
Low
Unassigned
zope.testrunner
Invalid
Low
Unassigned

Bug Description

When layers are stacked a setUp may be called multiple times:

class LayerA(object):
    @classmethod
    def setUp(cls):
        print "foo'

class LayerB(LayerA):
    pass

A test using LayerB will print "foo" twice.

Revision history for this message
Tres Seaver (tseaver) wrote :

Layers which don't define setUp and tearDown are kind of beside the point.

Changed in zope.testing:
importance: Undecided → Low
status: New → Triaged
Changed in zope.testrunner:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Jonathan Lange (jml) wrote :

Note also:

class LayerA(object):
    def setUp(self):
        print "foo"

class LayerB(LayerA):
    def setUp(self):
        print "bar"

A test using LayerB will print "foo" then "bar". This is:
  1. Completely unlike practically any other Python code
  2. Apparently a deliberate decision made by zope.testing.

Although I don't like this behaviour, I think there's a compelling case for this bug being marked Wontfix – it's just how layers work.

Tres, we frequently define layers that don't define setUp and tearDown in order to have a test use more than one layer.

Revision history for this message
Christian Zagrodnick (zagy) wrote : Re: [Bug 544138] Re: Testrunner calls setUp/tearDown of super class when layers do not define setUp/tearDown themselves

On 25.08.2010, at 17:48, Jonathan Lange wrote:

> Note also:
>
> class LayerA(object):
> def setUp(self):
> print "foo"
>
> class LayerB(LayerA):
> def setUp(self):
> print "bar"
>
> A test using LayerB will print "foo" then "bar". This is:
> 1. Completely unlike practically any other Python code
> 2. Apparently a deliberate decision made by zope.testing.

Sure. That's fine with me and I like that.

>
> Although I don't like this behaviour, I think there's a compelling case
> for this bug being marked Wontfix – it's just how layers work.
>
> Tres, we frequently define layers that don't define setUp and tearDown
> in order to have a test use more than one layer.

Actually testSetUp and testTearDown are also affected by this bug. If one layer A should define testSetUp all layers inherited from A need to define testSetUp to avoid superfluous calls to testSetUp.

--
Christian Zagrodnick · <email address hidden>
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 0 · fax +49 345 1229889 1
Zope and Plone consulting and development

Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.testing project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.testing.

Changed in zope.testing:
status: Triaged → Invalid
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.testrunner project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.testrunner.

Changed in zope.testrunner:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.