[Zope-dev] zope.testing.testrunner.debug.post_mortem and try/finally

Marius Gedminas marius at gedmin.as
Wed Dec 2 13:34:29 EST 2009


On Wed, Dec 02, 2009 at 09:08:51AM -0800, Ross Patterson wrote:
> When a try/finally clause is (appropriately) used to do cleanup after an
> exception during a test run, it often tears down parts of the fixture
> that are needed in order to do useful post_mortem debugging of the
> exception, such as closing the request or db connections.  What is the
> best way to do post_mortem debugging with the stack in the state it was
> at the time of the exception?

What I always do is find the line of code that raises the exception and
wrap it with

    try:
        ...
    except:
        import pdb; pdb.set_trace()

which is more or less exactly what you do:

> For a while now, I've been repeatedly modifying eggs in my development
> environment at the relevant try/finally clauses to invoke post_mortem
> before the tear down is done, sub-optimal to say the least.  :)  I find
> myself doing it often its time to invest in a better way.

Worst part is when you use a shared buildout egg cache and forget to
undo your experimental changes.

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3 consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20091202/bb3fc7aa/attachment.bin 


More information about the Zope-Dev mailing list