ipdb与python unittest模块

Joh*_*ohn 12 python unit-testing ipdb

当使用python的unittest模块运行测试时,有没有方便的方法来获取异常的ipdb调试器?

使用调试python代码很方便ipython --pdb my_script.py.但是,当我使用unittest模块时,用

class MyTestCase(unittest.TestCase):
    def runTest(self):
        x = 0
        y = 3/x
Run Code Online (Sandbox Code Playgroud)

unittest捕获异常并退出.

arm*_*mak -1

您可以在 ipython 中设置一个 %pdb 标志。如果发生任何异常,它将调用调试器。