On 04:18 pm, tsea...@palladion.com wrote:

Just as a point of reference:  zope.testing[1] has a "layer" feature
which is used to support this usecase:  a layer is a class namedd as an
attribute of a testcase, e.g.:

 class FunctionalLayer:
    @classmethod
    def setUp(klass):
        """ Do some expesnive shared setup.
        """
    @classmethod
    def tearDown(klass):
        """ Undo the expensive setup.
        """

 class MyTest(unittest.TestCase):
     layer = FunctionalLayer

The zope.testing testrunner groups testcase classes together by layer:
each layer's setUp is called, then the testcases for that layer are run,
then the layer's tearDown is called.

Other features:

- - Layer classes can define per-testcase-method 'testSetUp' and
'testTearDown' methods.

- - Layers can be composed via inheritance, and don't need to call base
 layers' methods directly:  the testrunner does that for them.

These features has been in heavy use for about 3 1/2 years with a lot of
success.


[1] http://pypi.python.org/pypi/zope.testing/

On the other hand:

 http://code.mumak.net/2009/09/layers-are-terrible.html

I've never used layers myself, so I won't personally weigh in for or against.

Jean-Paul
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to