[Grok-dev] grokproject configures z3c.testsetup instead of grok.testing

Kevin Teague kevin at bud.ca
Mon Mar 9 16:09:22 EDT 2009


The default 'tests.py' is:

import os.path
import z3c.testsetup
import sampleapp
from zope.app.testing.functional import ZCMLLayer


ftesting_zcml = os.path.join(
    os.path.dirname(sampleapp.__file__), 'ftesting.zcml')
FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__,
'FunctionalLayer',
                            allow_teardown=True)

test_suite = z3c.testsetup.register_all_tests('sampleapp')

This is functionaly equivalent to:

import grok
test_suite = grok.testing.register_all_tests('sampleapp')

The only difference being that the layer_name is 'FunctionalLayer'
versus 'GrokFunctionalLayer'. grok.testing.register_all_tests()
takes additional *args and **kwargs as input and passes them to
z3c.testsetup.TestCollector constructor, and will also respectfully
allow you to override the 'zcml_config' and 'layer_name' settings.

To further confuse the situation, z3c.testsetup will fallback to
using a package's 'ftesting.zcml' file as the default zcml_config.
And if no 'layer_name' is specified, then it falls back to
'FunctionalLayer' for the layer_name. In fact, because
grok.testing.register_all_tests respects settings overrides, this
default name in z3c.testsetup overrides the 'GrokFunctionalLayer' one
specificed in grok.testing! In fact, the defaults for z3c.testsetup
are
sufficient that one could put in tests.py:

import z3c.testsetup
import sampleapp

# The functional layer is configured by default to read it's
# ZCML configuration from the package's 'ftesting.zcml' file.
test_suite = z3c.testsetup.register_all_tests('sampleapp')

And get the same thing - with the exception of the allow_teardown
setting,
(which normally defaults to False). This means that
grok.testing.register_all_tests() isn't doing anything other than
being
another place to access the same function.

So the question is, is there any point in having a
grok.testing.register_all_tests()? Should this just be marked as BBB
and we should all just use z3c.testsetup.register_all_tests()? Or
should
grok.tessting.register_all_tests() just be updated so that it creates
the
default functional layer with allow_teardown=True, and then the
default
tests.py for a Grok-based package can simply be:

import grok

# The functional layer of the test suite will use the 'ftesting.zcml'
file
# in this package for it's ZCML configuration.
test_suite = grok.testing.register_all_tests('sampleapp')


More information about the Grok-dev mailing list