跳转到主要内容

启用子进程的Python覆盖率

项目描述

此包安装一个.pth文件,该文件在后续运行中启用此python前缀/虚拟环境中的coveragepy process_startup功能。

参见: http://nedbatchelder.com/code/coverage/subprocess.html

演示

$ virtualenv tmpenv
$ . tmpenv/bin/activate
$ pip install coverage-enable-subprocess
$ touch .coveragerc
$ export COVERAGE_PROCESS_START=$PWD/.coveragerc
$ echo 'print("oh, hi!")' > ohhi.py
$ python ohhi.py
oh, hi!

$ coverage report
Name                              Stmts   Miss  Cover
-----------------------------------------------------
/etc/python2.6/sitecustomize.py       5      1    80%
ohhi.py                               1      0   100%
tmpenv/lib/python2.6/site.py        433    392     9%
-----------------------------------------------------
TOTAL                               439    393    10%

对于需要在测试运行期间进行cd的项目,并并行运行许多进程,我确保导出$TOP变量,并使用此.coveragerc

[run]
parallel = True
branch = True
data_file = $TOP/.coverage

[report]
exclude_lines =
    # Have to re-enable the standard pragma
    \#.*pragma:\s*no.?cover

    # we can't get coverage for functions that don't return:
    \#.*never returns
    \#.*doesn't return

    # Don't complain if tests don't hit defensive assertion code:
    ^\s*raise Impossible\b
    ^\s*raise AssertionError\b
    ^\s*raise NotImplementedError\b
    ^\s*return NotImplemented\b

    # Don't complain if tests don't hit re-raise of unexpected errors:
    ^\s*raise$

    # if main is covered, we're good:
    ^\s*exit\(main\(\)\)$
show_missing = True

[html]
directory = $TOP/coverage-html

# vim:ft=dosini

项目详情


下载文件

下载适合您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

coverage_enable_subprocess-1.0.tar.gz (2.7 kB 查看哈希值)

上传时间:

构建分布

coverage_enable_subprocess-1.0-py2.py3-none-any.whl (4.0 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下提供支持