Python Unit Testing: Automatically Running the Debugger when a test fails

前端 未结 6 1769
日久生厌
日久生厌 2020-12-02 08:24

Is there a way to automatically start the debugger at the point at which a unittest fails?

Right now I am just using pdb.set_trace() manually, but this is very tedio

6条回答
  •  天涯浪人
    2020-12-02 09:12

    Third party test framework enhancements generally seem to include the feature (nose and nose2 were already mentioned in other answers). Some more:

    pytest supports it.

    pytest --pdb
    

    Or if you use absl-py's absltest instead of unittest module:

    name_of_test.py --pdb_post_mortem
    

提交回复
热议问题