Debugging functional tests

Matt Wilkes - September 19th, 2008

I’m sure I’m not the only one that’s got fed right up with having a functional plone test that doesn’t quite work right.  PDB to the rescue, you’d think, but you end up with errors like

(Pdb) admin.open("http://nohost/plone/@@")
*** HTTPError: HTTP Error 500: Internal Server Error

Well, thanks Python.  That’s grand.  I used to have lots of fun with a testbrowser visiting http://nohost/plone/error_log/manage_main and poring through HTML.  Not ideal.

So I’ve automated it, introducing teamrubber.pdberrorlog

The above example would then become:

(Pdb) import teamrubber.pdberrorlog
(Pdb) admin.open("http://nohost/plone/@@")
*** HTTPError: HTTP Error 500: Internal Server Error
(Pdb) errorlog
Error: 1221836644.810.255510740468 (TypeError : 'unicode' object is not callable)
(Pdb) errorlog 1221836644.810.255510740468
Traceback (innermost last):
Module ZPublisher.Publish, line 106, in publish
Module ZPublisher.BaseRequest, line 327, in traverse
Module Products.Five.traversable, line 118, in __bobo_traverse__
Module zope.app.traversing.adapters, line 124, in traverse
Module zope.app.traversing.adapters, line 163, in traversePathElement
Module zope.app.traversing.namespace, line 121, in namespaceLookup
Module zope.app.traversing.namespace, line 363, in traverse
Module zope.component, line 165, in queryMultiAdapter
Module zope.component.site, line 75, in queryMultiAdapter
Module zope.interface.adapter, line 475, in queryMultiAdapter
TypeError: 'unicode' object is not callable

It’s quite crude, but hopefully it will be useful to people.

2 Responses to “Debugging functional tests”

  1. Lennart Regebro says:

    There is a handleErrors = False setting on the browser object that make it print out the error instead. It seems to have pretty much the same effect.

  2. sig says:

    And the following command is handy, too :

    >>> print self.portal.error_log.getLogEntries()[0]['tb_text']

Leave a Reply