[Zope3-dev] functional testing ugliness

Anthony Baxter anthony@interlink.com.au
Fri, 01 Aug 2003 16:34:26 +1000


We're writing some functional tests for the Catalog, and ran across a
really unpleasant bug (or at least wart) in the functional testing.

As part of the testing of adding, we have code like this:

    response = self.publish("/felix_the/+/AddFieldIndexToCatalog=dctitle",
		    basic='mgr:mgrpw', 
		    form={'field.interface.search': 
			  u'zope.app.interfaces.dublincore.IZopeDublinCore',
			  'field.field_name':'Title'})

Initially we had the URL as "/felix_the/+/AddFieldIndexToCatalog%3Ddctitle"
(snarfed out of a browser), and this led to an infinite recursion in the
publishing code when running the tests.

Traceback (most recent call last):
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/catalog/ftests/test_catalo
g.py", line 31, in testAddCatalog
    form={'field.interface.search':
  File "/home/anthony/src/zope/Zope3Head/src/zope/testing/functional.py", line 1
98, in publish
    publish(request, handle_errors=handle_errors)
  File "/home/anthony/src/zope/Zope3Head/src/zope/publisher/publish.py", line 13
5, in publish
    object = request.traverse(object)
  File "/home/anthony/src/zope/Zope3Head/src/zope/publisher/browser.py", line 61
2, in traverse
    ob = super(BrowserRequest, self).traverse(object)
  File "/home/anthony/src/zope/Zope3Head/src/zope/publisher/http.py", line 439, 
in traverse
    ob = super(HTTPRequest, self).traverse(object)
  File "/home/anthony/src/zope/Zope3Head/src/zope/publisher/base.py", line 252, 
in traverse
    subobject = publication.traverseName(
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/publication/publicationtra
verse.py", line 73, in traverseName
    ob2 = ob.publishTraverse(request, nm)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/publisher/browser/viewmeta
.py", line 324, in publishTraverse
    return m(request, name)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/browser/container/adding.p
y", line 80, in publishTraverse
    return zapi.ContextSuper(Adding, self).publishTraverse(
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/browser/container/adding.p
y", line 80, in publishTraverse
    return zapi.ContextSuper(Adding, self).publishTraverse(

[....many many many copies of these two lines....]

  File "/home/anthony/src/zope/Zope3Head/src/zope/app/browser/container/adding.p
y", line 80, in publishTraverse
    return zapi.ContextSuper(Adding, self).publishTraverse(
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/browser/container/adding.p
y", line 74, in publishTraverse
    view = zapi.queryView(self, view_name, request)
  File "/home/anthony/src/zope/Zope3Head/src/zope/component/__init__.py", line 1
52, in queryView
    'Views').queryView(object, name, request, default)
  File "/home/anthony/src/zope/Zope3Head/src/zope/component/view.py", line 64, i
n queryView
    for layername in getSkin(object, skin, type):
  File "/home/anthony/src/zope/Zope3Head/src/zope/component/__init__.py", line 1
39, in getSkin
    Skins).getSkin(wrapped_object, name, view_type)
  File "/home/anthony/src/zope/Zope3Head/src/zope/component/__init__.py", line 4
3, in getService
    return getServiceManager(context).getService(name)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/services/service.py", line
 110, in getService
    return getNextService(wrapped_self, name)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/component/nextservice.py",
 line 35, in getNextService
    service = queryNextService(context, name)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/component/nextservice.py",
 line 42, in queryNextService
    sm = getNextServiceManager(context)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/component/nextservice.py",
 line 56, in getNextServiceManager
    sm = getServiceManager_hook(context)
  File "/home/anthony/src/zope/Zope3Head/src/zope/app/component/hooks.py", line 
61, in getServiceManager_hook
    wrapped = isWrapper(context)
RuntimeError: maximum recursion depth exceeded

This is a bit nasty. I'm not sure what the appropriate fix is, tho...

Anthony

--
Anthony Baxter     <anthony@interlink.com.au>
It's never too late to have a happy childhood.