[Zope-dev] Re: Unit Test Failures

Philipp von Weitershausen philipp at weitershausen.de
Tue Dec 20 04:11:45 EST 2005


Lennart Regebro wrote:
> On the actual problem, this is a big red flag for me:
>
>   'isinstance(zapi.getSiteManager(), FiveSiteManager)': True,
>
> Fails. So, it's not a FivesiteManager. What is it? None, or something else?

It's the global site manager if not the FiveSiteManager.

> Since this seems to be a cleanup issue, my guess is: Something else.
> Probably another one of the site tests doesn't clean up (and that's
> probably my fault).

Nope, it's really nobody's fault but mine. And the site tests weren't responsible for
sure. So, before I explain this issue in detail, let me say: I've already fixed this in
the Five repo after remembering a peculiarity in Zope 3.1+ last night. I just haven't had
the time yet to merge it to the Zope repo, will do that first thing I'm back in SVN
check-in range (on the road right now).

So, here's the deal:
zope.component doesn't have a clue about local sites. All it knows is the global site
manager. However, it *does* provide a hook so that other software can influence where the
site manager is found. zope.app.component (notice the app here) provides such a hook that
knows about the site in the thread local. That's how zope.component in the end *does*
find local sites, because it calls the hook.

Now, in Zope X3 3.0, the hooks were set via ZCML using the <hook /> directive. This
directive was ripped out in Zope 3.1 and replaced by a simple function,
zope.app.component.hooks.setHooks(). This function is called upon Zope startup by
zope.app.appsetup.appsetup.config() so that the hooks are set when Zope is running. A
clean-up function is registered with the general test clean-up facility in Zope 3 that
clears the hook. So, a unit test would normally not see the hooks *if* it is run *after*
a test that has used e.g. placelesssetup.tearDown().

So, in the end, it was actually a problem of cleaning up too much, not too little. I've
already had to deal with this problem in the utility tests and solved it there, but
didn't remember it when I initially wrote the functional test. That's why my debugging
efforts were futile back then.

I guess this needs to be handled a better way, but I leave it to Stephan (who I think is
responsible for the hooks handling) to decide what to do.

Philipp


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


More information about the Zope-Dev mailing list