<div class="gmail_extra">That didn't work either.<br><br>I did some thorough test until I reached to a case where only two integration tests are declared within homeviva.testing (the rest of them are unittests):<br><br>
#Python libraries<br>import unittest<br><br>#Grok & Zope<br>from zope.app.wsgi.testlayer import BrowserLayer<br><br>#The homeviva/consworks namespace<br>import homeviva.testing<br>from homeviva.testing.fixtures import (<br>
setUpConsworksFixture,<br> tearDownConsworksFixture<br>)<br><br>class FooTestCase(unittest.TestCase):<br> layer = BrowserLayer(homeviva.testing)<br><br> def setUp(self):<br> zodb_root = self.layer.get_app().wsgi_stack.root_factory()<br>
setUpConsworksFixture(self, zodb_root)<br><br> def tearDown(self):<br> zodb_root = self.layer.get_app().wsgi_stack.root_factory()<br> tearDownConsworksFixture(self, zodb_root)<br><br> def test_sanity(self):<br>
self.assertTrue(0==0)<br><br>class BarTestCase(unittest.TestCase):<br> layer = BrowserLayer(homeviva.testing)<br><br> def setUp(self):<br> zodb_root = self.layer.get_app().wsgi_stack.root_factory()<br>
setUpConsworksFixture(self, zodb_root)<br><br> def tearDown(self):<br> zodb_root = self.layer.get_app().wsgi_stack.root_factory()<br> tearDownConsworksFixture(self, zodb_root)<br><br> def test_sanity(self):<br>
self.assertTrue(0==0)<br><br>And these are the fixture functions:<br><br>import time<br>from grok.util import create_application<br><br>def setUpConsworksFixture(self, zodb_root):<br> #select appname<br> self.appname = ''.join(str(time.time()).split('.'))<br>
<br><br>def tearDownConsworksFixture(self, zodb_root):<br> del zodb_root[self.appname]<br> del self.consworks_app<br><br>There's no custom layer anymore and I'm still getting the traceback. The traceback is thrown only If I run all the tests (e.g. bin/test -s homeviva.testing) and not when I run a particular test (bin/test -s homeviva.testing -t FooTestCase). Also, it is never thrown when adding one instance through the Grok controlpanel.<br>
<br>The Consworks Object does some complex application initalization based on decorators. Would that be the cause of this issue?<br><br>---<br>Noe<br><br><div class="gmail_quote">2012/4/25 Jan-Jaap Driessen <span dir="ltr"><<a href="mailto:jdriessen@minddistrict.com" target="_blank">jdriessen@minddistrict.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 25 April 2012 07:17, Noe Nieto <<a href="mailto:nnieto@noenieto.com">nnieto@noenieto.com</a>> wrote:<br>
> Hi,<br>
><br>
> I have a package homeviva.testing that holds all tests from our aplication.<br>
> Inside that package I added a subclass of<br>
> zope.app.wsgi.testlayer.BrowserLayer that will add an instance of our grok<br>
> application add then add some more dummy data as a way to provide a common<br>
> test fixture to all of our integration test.<br>
><br>
> The layer looks like this:<br>
><br>
> from zope.app.wsgi.testlayer import BrowserLayer<br>
><br>
> class HomeVivaIntegrationLayer(BrowserLayer):<br>
> """<br>
> Integration Layer for HomeViva.<br>
> """<br>
> consworks_app = None<br>
><br>
> def testSetUp(self):<br>
> super(HomeVivaIntegrationLayer, self).testSetUp()<br>
><br>
> #Add test app<br>
> from consworks.app import Consworks<br>
> zodb_root = self.getRootFolder()<br>
> zodb_root['app'] = self.consworks_app = Consworks()<br>
><br>
> #Fire up events<br>
> import grok<br>
> grok.notify(grok.ApplicationInitializedEvent(self.consworks_app))<br>
><br>
> #... more stuff here<br>
><br>
> When I run my tests individually all goes fine, but if I try to run all the<br>
> tests within the package, no tests are run and a traceback is printed:<br>
><br>
> $ bin/test -s homeviva.testing<br>
> Running homeviva.testing.HomeVivaIntegrationLayer tests:<br>
</div></div>...<br>
<div class="im">> What am I doing wrong?<br>
<br>
</div>Hi Noe,<br>
<br>
We had the same issue a while ago. JW knows the details, I only<br>
remember we moved the setup of test fixtures from the layer's<br>
testSetUp to the setUp of the individual TestCases.<br>
<br>
Cheers,<br>
<br>
JJ<br>
</blockquote></div><br><br clear="all"><br>-- <br><span style="color:rgb(255,204,102)">---</span><br>
<span style="color:rgb(204,153,51)">Noe Nieto</span><br>
NNieto Consulting Services<br>
M: <a href="mailto:nnieto@noenieto.com" target="_blank">nnieto@noenieto.com</a><br>
W: <a href="http://noenieto.com" target="_blank">http://noenieto.com</a><br>
T: <a href="https://twitter.com/#%21/tzicatl" target="_blank">@tzicatl</a><br>Li: <a href="http://www.linkedin.com/profile/view?id=84300665" target="_blank">Perfil en LinkedIn</a><br><br>
</div>