[Grok-dev] ComponentLookupError: (<InterfaceClass zope.intid.interfaces.IIntIds>, '') on integration tests

Noe Nieto nnieto at noenieto.com
Tue Mar 20 22:12:36 UTC 2012


I'm writing some integration test for our products. I'm placing that tests
in a separate package: homeviva.testing

When I run my test, with zope.testrunner, I'm always having the following
traceback:

Error in test test_consworks_views
(homeviva.testing.tests.test_dbmodels.ConsworksTestCase)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/case.py", line 318, in run
    self.setUp()
  File
"/home/tzicatl/Aplicaciones/Codigo/HomeViva/homeviva_trunk/src/homeviva.testing/homeviva/testing/tests/test_dbmodels.py",
line 26, in setUp
    self.root['app'] = Consworks()
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.container-3.12.0-py2.7-linux-x86_64.egg/zope/container/folder.py",
line 95, in __setitem__
    setitem(self, self.data.__setitem__, name, object)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.container-3.12.0-py2.7-linux-x86_64.egg/zope/container/contained.py",
line 559, in setitem
    notify(event)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.event-3.5.0_1-py2.7.egg/zope/event/__init__.py",
line 23, in notify
    subscriber(event)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/event.py",
line 24, in dispatch
    zope.component.subscribers(event, None)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/_api.py",
line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/registry.py",
line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.interface-3.6.1-py2.7-linux-x86_64.egg/zope/interface/adapter.py",
line 585, in subscribers
    subscription(*objects)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/event.py",
line 32, in objectEventNotify
    zope.component.subscribers((event.object, event), None)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/_api.py",
line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/registry.py",
line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.interface-3.6.1-py2.7-linux-x86_64.egg/zope/interface/adapter.py",
line 585, in subscribers
    subscription(*objects)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/grok-1.4.3-py2.7.egg/grok/meta.py",
line 175, in __call__
    self._createIntIds(site)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/grok-1.4.3-py2.7.egg/grok/meta.py",
line 216, in _createIntIds
    setupUtility(site, intids, IIntIds)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/grokcore.site-1.5-py2.7.egg/grokcore/site/meta.py",
line 108, in setupUtility
    container[name_in_container] = utility
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.container-3.12.0-py2.7-linux-x86_64.egg/zope/container/btree.py",
line 112, in __setitem__
    setitem(self, self._setitemf, key, value)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.container-3.12.0-py2.7-linux-x86_64.egg/zope/container/contained.py",
line 560, in setitem
    notifyContainerModified(container)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.container-3.12.0-py2.7-linux-x86_64.egg/zope/container/contained.py",
line 332, in notifyContainerModified
    notify(ContainerModifiedEvent(object, *descriptions))
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.event-3.5.0_1-py2.7.egg/zope/event/__init__.py",
line 23, in notify
    subscriber(event)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/event.py",
line 24, in dispatch
    zope.component.subscribers(event, None)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/_api.py",
line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/registry.py",
line 321, in subscribers
    return self.adapters.subscribers(objects, provided)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.interface-3.6.1-py2.7-linux-x86_64.egg/zope/interface/adapter.py",
line 585, in subscribers
    subscription(*objects)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.catalog-3.8.1-py2.7.egg/zope/catalog/catalog.py",
line 197, in reindexDocSubscriber
    id = component.getUtility(IIntIds, context=cat).queryId(ob)
  File
"/home/tzicatl/Aplicaciones/Buildout/eggs/zope.component-3.10.0-py2.7.egg/zope/component/_api.py",
line 169, in getUtility
    raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass zope.intid.interfaces.IIntIds>, '')

My testcase looks like this:


class ConsworksTestCase(unittest.TestCase):
    """
    TestCase for the Consworks app object
    """
    layer = HomeVivaIntegrationLayer(homeviva.testing)

    def setUp(self):
        #Add test app
        from consworks.app import Consworks
        self.root = self.layer.getRootFolder()
        self.root['app'] = Consworks()
        self.app = self.root['app']

   def test_here(self):
       ....

I tried to manually  register a Intid utility in my layer, but with no
results.

from zope.app.wsgi.testlayer import BrowserLayer
from zope.site.hooks import getSiteManager
from zope.intid.interfaces import IIntIds
from zope.intid import IntIds

class HomeVivaIntegrationLayer(BrowserLayer):
    """
    Integration Layer for HomeViva.
    """

    def testSetUp(self):
        super(HomeVivaIntegrationLayer, self).testSetUp()
        # root = self.getRootFolder()
        # sm = getSiteManager()
        # sm.registerUtility(IntIds(), provided=IIntIds)
        # import pdb; pdb.set_trace( )



Anyone has hit this error? how did you fixed it?



-- 
---
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/20120320/07fb7f77/attachment.html>


More information about the Grok-dev mailing list