[Grok-dev] How to hook up custom layers with z3c.testsetup?
Ivo van der Wijk
vladdrac at gmail.com
Fri Jun 20 12:44:20 EDT 2008
>> class IntegrationDocTester(UnitDocTestSetup):
>> """ handle integration tests """
>> integration_zcml = os.path.join(
>> os.path.dirname(__file__), 'integrationtesting.zcml')
>> layer = ZCMLLayer(integration_zcml, __name__, 'IntegrationLayer')
> I'm not sure why you made thos class attributes...
>> regexp_list = [
> It sucks having to reinvent the regex here :(
It's basically how the existing testsetups are defined - see
z3c.testsetup.doctesting. Now that I look at it - I could just as well
have defined layer in getTestSuite(), assuming the base class doesn't
somehow depend on it (don't think so)
>> def getTestSuite(self):
>> suite = UnitDocTestSetup.getTestSuite(self)
>> suite.layer = self.layer
>> return suite
>> class MyTestCollector(TestCollector):
>> """ also collects integration tests """
>> handled_getters = TestCollector.handled_getters + [IntegrationDocTester]
>> test_suite = MyTestCollector('your.package')
> It seems it's almost more work to use z3c.testsetup than just writing down
> an old school test_suite() function. It'd be nice if z3c.testsetup could
> work with arbitrary layers, like I've suggested in my reply to Uli.
I agree - I just had to try :)
Drs. I.R. van der Wijk / m3r Consultancy B.V.
Linux/Python/Zope/Plone and Open Source solutions
PO-box 51091, 1007 EB Amsterdam, The Netherlands
Email: ivo <at> m3r.nl Web: http://m3r.eu/
More information about the Grok-dev