python鼻子覆盖插件太彻底(强制pylib选项)
我使用的是nose 1.3.0和coverage 3.7 在命令行上运行python鼻子覆盖插件太彻底(强制pylib选项),python,unit-testing,code-coverage,nose,coverage.py,Python,Unit Testing,Code Coverage,Nose,Coverage.py,我使用的是nose 1.3.0和coverage 3.7 在命令行上运行 coverage run test_myfile.py coverage report 生成一个报告,该报告仅限于myfile.py中的函数: Name Stmts Miss Branch BrMiss Cover ---------------------------------------------------- myfile 157 27
coverage run test_myfile.py
coverage report
生成一个报告,该报告仅限于myfile.py中的函数:
Name Stmts Miss Branch BrMiss Cover
----------------------------------------------------
myfile 157 27 38 12 80%
test_myfile 81 16 16 13 70%
----------------------------------------------------
TOTAL 238 43 54 25 77%
但是,如果我尝试使用nose的覆盖率插件,覆盖率将扩展到已安装的python库,但速度较慢,结果混乱:
nosetests --with-coverage myfile.py
这里的覆盖范围扩展到安装库中所有使用过的软件包的所有血淋淋的细节(手动缩短报告):
这似乎相当于在命令行上指定:
coverage run --pylib test_myfile.py
我如何才能让nose coverage插件不深入研究已安装的python库?我想您可能需要尝试类似的方法 你应该。下面是一个例子:
# .coveragerc
[report]
include = *.py
omit =
tests.py
*_test.py
*_tests.py
*/site-packages/*
*/migrations/*
nosetests --with-coverage --cover-package=myfile --cover-tests
# .coveragerc
[report]
include = *.py
omit =
tests.py
*_test.py
*_tests.py
*/site-packages/*
*/migrations/*