* Stephan Richter <stephan.rich...@gmail.com> [2011-12-05 09:16]:
> On Monday, December 05, 2011 12:43:35 PM Wolfgang Schnerring wrote:
> > So we decided to solve our most immediate needs (that are not taken
> > care of by plone.testing's stacking solution of the global registry),
> > namely temporarily altering utility/adapter/handler registrations.
> Why did you not just wrap the config in a z3c.basegeistry directive?

I'm afraid I don't understand how that could help in what I'd like to
do. The use case I'm concerned with looks roughly like this:

    def test_client_code_that_uses_IFoo_utility_correctly(self):
        fake_utility = mock.Mock()
        fake_utility.underlying_method.return_value = 'canned response'
        self.zca.patch_utility(fake_utility, IFoo)

With the additional conditions that
- I'm probably loading configure.zcml in the layer of this test, which
defines real IFoo (and, possibly, IBar) utilities.
- The client code under test might (or might not) use IBar; either way,
I don't care, and certainly don't want to have to mock it, too, for
*this* test.
- Other tests will likewise want the real IFoo implementation.

In other words, I want to replace the utility precisely for this test,
isolated from all other tests, and isolated from the layer setup
below. plone.testing's stacking approach might help, but only as long
as only zope.component.getGlobalSiteManager() is concerned, and as
long as I'm only adding or exchanging stuff (come to think of it, I
should go and check whether I can "remove" things registered in
__bases__ by registering None in the stacked registry...).

As far as I can tell, z3c.baseregistry merely introduces another
registry (with __bases__ set up sensibly), so I don't think that can
help here, or can it?


Wolfgang Schnerring · email/jabber: w...@gocept.com · software development
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 219401 0 · fax +49 345 1229889 1
Python, Pyramid, Plone, Zope - consulting, development, hosting, operations

Attachment: signature.asc
Description: Digital signature

Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to