Skip to main content
 首页 » 编程设计

python之Nose 测试 : error: no such option: --with-doctest

2024年11月01日10birdshome

我试图在所有模块中运行所有 doctests,但得到以下结果:

$ nosetests --with-doctest 
Usage: nosetests [options] 
 
nosetests: error: no such option: --with-doctest 

有些东西正在崩溃,但很难说到底是什么。我已经修复了 nosetests --with-doctest -vvv 显示的所有故障,但它没有帮助。

知道如何调试它吗?

nose==1.3.0

更新:

在这种情况下,使用 py.test 运行更愉快,并且显示失败的测试而不会崩溃:

py.test --doctest-modules 

我仍然不知道 Nose 发生了什么。

请您参考如下方法:

在使用 py.test 修复失败的测试后,它开始以同样的方式崩溃 py.test: error: no such option: --doctest-modules,但它提供了更好的错误消息,让我感到震惊的是 optparse.OptionParser 不受 if __name__ == "__main__": 保护。现在,nose 和 py.test 的测试工作正常。