我不确定如何让 nose 模块的 __main__
处理程序工作。我在测试模块的末尾有这个:
if __name__ == "__main__":
import nose
nose.main()
这给了我:
----------------------------------------------------------------------
Ran 0 tests in 0.002s
OK
但是我通过命令行运行同样的东西,它找到测试并执行它们:
MacBook-Pro:Storage_t meloam$nosetests FileManager_t.py
............E..
======================================================================
ERROR: testStageOutMgrWrapperRealCopy (WMCore_t.Storage_t.FileManager_t.TestFileManager)
----------------------------------------------------------------------
剪辑
----------------------------------------------------------------------
Ran 15 tests in 0.082s
FAILED (errors=1)
我一直在尝试向 nose.main() 传递不同的参数,但我找不到任何有效的方法。我是否漏掉了一些非常明显的东西?
谢谢
最佳答案
为了后代,这就是我使用的:
if __name__ == '__main__':
import nose
nose.run(argv=[__file__, '--with-doctest', '-vv'])
--with-doctests
还将在同一个文件中执行您的 doctests。
关于python - 有没有办法让 python 的 nose 模块在 __main__ 和命令行中同样工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3160551/