pdb + unittest

Chris Green cmg at dok.org
Mon Apr 12 22:52:02 EDT 2004


After forcing myself to start unittest each module I write from the
get go versus writing some simple apps to excercise some subset of
functionality, I realized it's pretty hard to use pdb + unittest.

The standard place is a test case is failing, aborting with an assert
and I want to debug the statement prior to find out what went wrong.

def test_method(self):
    res = self.obj.do_something()
    self.assertEqual(res, 42)
    res = foo(res)


Often I want to debug at the first do something so I replace it with:

 import pdb
 res = pdb.runcall(self.obj.do_something)

This work great but I don't want pdb to exit from interactive control
until perhaps after the foo(res) call.

Is there a simple way I could get pdb to shove itself higher up in the
flow control?  How about a mildly complex one? :)

Thanks,
Chris
-- 
Chris Green <cmg at dok.org>
A watched process never cores.



More information about the Python-list mailing list