[Grok-dev] zope.keyreference.interfaces.NotYet is thrown while running tests

Noe Nieto nnieto at noenieto.com
Wed Apr 25 18:54:06 UTC 2012


That didn't work either.

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):

#Python libraries
import unittest

#Grok & Zope
from zope.app.wsgi.testlayer import BrowserLayer

#The homeviva/consworks namespace
import homeviva.testing
from homeviva.testing.fixtures import (
    setUpConsworksFixture,
    tearDownConsworksFixture
)

class FooTestCase(unittest.TestCase):
    layer = BrowserLayer(homeviva.testing)

    def setUp(self):
        zodb_root = self.layer.get_app().wsgi_stack.root_factory()
        setUpConsworksFixture(self, zodb_root)

    def tearDown(self):
        zodb_root = self.layer.get_app().wsgi_stack.root_factory()
        tearDownConsworksFixture(self, zodb_root)

    def test_sanity(self):
        self.assertTrue(0==0)

class BarTestCase(unittest.TestCase):
    layer = BrowserLayer(homeviva.testing)

    def setUp(self):
        zodb_root = self.layer.get_app().wsgi_stack.root_factory()
        setUpConsworksFixture(self, zodb_root)

    def tearDown(self):
        zodb_root = self.layer.get_app().wsgi_stack.root_factory()
        tearDownConsworksFixture(self, zodb_root)

    def test_sanity(self):
        self.assertTrue(0==0)

And these are the fixture functions:

import time
from grok.util import create_application

def setUpConsworksFixture(self, zodb_root):
    #select appname
    self.appname = ''.join(str(time.time()).split('.'))


def tearDownConsworksFixture(self, zodb_root):
    del zodb_root[self.appname]
    del self.consworks_app

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.

The Consworks Object does some complex application initalization based on
decorators. Would that be the cause of this issue?

---
Noe

2012/4/25 Jan-Jaap Driessen <jdriessen at minddistrict.com>

> On 25 April 2012 07:17, Noe Nieto <nnieto at noenieto.com> wrote:
> > Hi,
> >
> > I have a package homeviva.testing that holds all tests from our
> aplication.
> > Inside that package I added a subclass of
> > zope.app.wsgi.testlayer.BrowserLayer that will add an instance of our
> grok
> > application add then add some more dummy data as a way to provide a
> common
> > test fixture to all of our integration test.
> >
> > The layer looks like this:
> >
> > from zope.app.wsgi.testlayer import BrowserLayer
> >
> > class HomeVivaIntegrationLayer(BrowserLayer):
> >     """
> >     Integration Layer for HomeViva.
> >     """
> >     consworks_app = None
> >
> >     def testSetUp(self):
> >         super(HomeVivaIntegrationLayer, self).testSetUp()
> >
> >         #Add test app
> >         from consworks.app import Consworks
> >         zodb_root = self.getRootFolder()
> >         zodb_root['app'] = self.consworks_app = Consworks()
> >
> >         #Fire up events
> >         import grok
> >         grok.notify(grok.ApplicationInitializedEvent(self.consworks_app))
> >
> >         #... more stuff here
> >
> > When I run my tests individually all goes fine, but if I try to run all
> the
> > tests within the package, no tests are run and a traceback is printed:
> >
> > $ bin/test -s homeviva.testing
> > Running homeviva.testing.HomeVivaIntegrationLayer tests:
> ...
> > What am I doing wrong?
>
> Hi Noe,
>
> We had the same issue a while ago. JW knows the details, I only
> remember we moved the setup of test fixtures from the layer's
> testSetUp to the setUp of the individual TestCases.
>
> Cheers,
>
> JJ
>



-- 
---
Noe Nieto
NNieto Consulting Services
M: nnieto at noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20120425/81b223cf/attachment.html>


More information about the Grok-dev mailing list