setting breakpoints with nosetests --pdb option

前端 未结 4 691
攒了一身酷
攒了一身酷 2021-01-29 20:51

nosetests --pdb let\'s me halt upon error or failure, but this is too late for my needs. Stepping through code during execution helps me debug where the problem is.

4条回答
  •  梦如初夏
    2021-01-29 21:03

    Even better than remembering to use -s is to use the set_trace variant that comes with Nose. Add

    from nose.tools import set_trace; set_trace()
    

    wherever you'd like to break in to the debugger. The stdin/out redirection will be taken care of for you. The only strange side effect I've run into is the inability to restart your code from within pdb (using run) while debugging during a nose run.

提交回复
热议问题