我想从 Python 脚本运行 NoseTest。但我不仅要运行它,还要测量测试覆盖率。

刚才我有以下代码:

import os
import sys
import nose

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))

import tests

if __name__ == "__main__":
    config = nose.config.Config(verbosity=3, stopOnError=False, argv=["--with-coverage"])
    result = nose.run(module=tests, config=config)

我应该添加什么来获得我的保险报告?

最佳答案

该死的!经过 Nose 测试的一些小调试后,我设法做到了!

if __name__ == "__main__":
    file_path = os.path.abspath(__file__)
    tests_path = os.path.join(os.path.abspath(os.path.dirname(file_path)), "tests")
    result = nose.run(argv=[os.path.abspath(__file__),
                            "--with-cov", "--verbosity=3", "--cover-package=phased", tests_path])

关于python - Nose 测试 : running with coverage from Python script,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30197717/

10-12 13:49