ProjectRoot - Module1 src/ tests/ - Module2 src/ tests/ ...
我想从根目录运行所有测试并计算覆盖率。这是我正在使用的命令
python -m coverage run --branch -m unittest **/tests/test*
在这里,我想排除某些目录。我该怎么做?
我尝试了一种方法 .coveragerc
.coveragerc
... omit = Module2/* ...
python -m coverage run --rcfile=.coveragerc --branch -m unittest **/tests/test*
但它仍然试图获取模块2进行测试。
[report] exclude_lines = pragma: no cover include = ../toolbox/*.py ../geometry_finder/*.py ../position_optimiser/*.py [html] directory = c:\tmp\Report
我现在尝试了以下方法:
[report] exclude_lines = pragma: no cover include = ../. omit = ../toolbox/*.py [html] directory = c:\tmp\Report
... 我没有看到工具箱的覆盖范围。所以我不能确定。代码的启动使用:
coverage run --branch .\unittest_package.py coverage html