views:

64

answers:

0

Is there a way to get nosetests --pdb to automatically show you the error you're trying to debug, as well as a backtrace, BEFORE dumping you into pdb? i.e. instead of:

awagner@hesse:/home/awagner/optimization/illumination_search$ nosetests --pdb
test_bool_rep (optimization.illumination_search.test_subset_search.SubsetSearchTest) ... ok
test_list_rep (optimization.illumination_search.test_subset_search.SubsetSearchTest) ... ok
test_string_rep (optimization.illumination_search.test_subset_search.SubsetSearchTest) ... > /home/awagner/optimization/illumination_search/subset_search.py(20)string_rep()
-> stringRep = ''.join([str(int(i in s)) for i in xrange(setSize)])
(Pdb) 

I would like to see something like:

ERROR: test_string_rep (optimization.illumination_search.test_subset_search.SubsetSearchTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/awagner/optimization/illumination_search/test_subset_search.py", line 15, in test_string_rep
    self.assertEqual(ss.string_rep(listRep), stringRep)
  File "/home/awagner/optimization/illumination_search/subset_search.py", line 20, in string_rep
    stringRep = ''.join([str(int(i in s)) for i in xrange(setSize)])
TypeError: an integer is required
-> stringRep = ''.join([str(int(i in s)) for i in xrange(setSize)])
(Pdb) 

If there's a much better way to interactively debug code within an automated/persistent unit testing infrastructure, I'd welcome suggestions as well.