On Wed, Jun 04, 2008 at 05:19:11PM +0200, Kai Diefenbach wrote: > to register a IntIds utility by startup I'm using following subscriber: > <snip> > ensureUtility(root_folder, IIntIds, '', IntIds, copy_to_zlog=False) <snip> > This is working when zope is running. > > I wonder why it isn't within tests.
Are you talking about unit or functional tests? > the code above is executed but the > IntIds utility is not available. This sounds like functional tests to me. > With: > > <snip> > > >>> from zope.app.intid.interfaces import IIntIds > >>> from zope.component import getUtility > >>> intids = getUtility(IIntIds) This looks more like a unit test to me. Are you setting the site in the test fixture? Local utilities can only be found when you set the site (running zope does this for you when processing requests) or pass some context to getUtility. > </snip> > > I get: > > File > "/Users/Kai/Zope/instances/iqpp.qab/src/iqppqab/actions/adapters/actions > .txt", line 28, in actions.txt > Failed example: > intids = getUtility(IIntIds) > Exception raised: ... > ComponentLookupError: (<InterfaceClass > zope.app.intid.interfaces.IIntIds>, '') > I guess I don't understand the whole SiteManager thing. Is there a > working example of how to setup a test environment with IntIds. zope/app/catalog/README.txt could be an example. I haven't looked deeply, but it seems that it is registering an IIntIds utility as a global utility, which is much simpler and therefore more suitable for tests. Regards, Marius Gedminas -- ... there is always a well-known solution to every human problem -- neat, plausible, and wrong. -- H. L. Mencken (1880-1956), "Prejudices"
Description: Digital signature
_______________________________________________ Zope3-users mailing list Zope3email@example.com http://mail.zope.org/mailman/listinfo/zope3-users