pysys.writer.coverage

Writers that collect and report on code coverage data.

PythonCoverageWriter

class pysys.writer.coverage.PythonCoverageWriter(logfile=None, **kwargs)[source]

Bases: pysys.writer.testoutput.CollectTestOutputWriter

Writer that collects Python code coverage files in a single directory and writes a coverage report during runner cleanup. Requires the “coverage.py” library to be installed.

To enable this, run with -XcodeCoverage (or -XpythonCoverage) and configure the destDir plugin property in pysysproject.xml (e.g. to __coverage_python.${outDirName}).

If coverage is generated, the directory containing all coverage files is published as an artifact named “PythonCoverageDir”. Optionally an archive of this directory can be generated by setting the destArchive property (see CollectTestOutputWriter), and published as “PythonCoverageArchive”.

Note that to maintain compatibility with pre-1.6.0 projects, a PythonCoverageWriter instance will be _automatically_ added to the project if the pythonCoverageDirA project property is set and none is explicitly configured; but the automatic addition is deprecated so you should explicity add this writer to your project if you need it.

New in version 1.6.0.

The following properties can be set in the project configuration for this writer (and see also pysys.writer.testoutput.CollectTestOutputWriter for inherited properties such as destArchive which produces a .zip of the destDir):

pythonCoverageArgs = ''

A string of command line arguments used to customize the coverage run and coverage html commands. Use “…” double quotes around any arguments that contain spaces.

For example:

<property name="pythonCoverageArgs" value="--rcfile=${testRootDir}/python_coveragerc"/>
includeCoverageFromPySysProcess = False

Set this to True to enable measuring coverage for this process (i.e. PySys), rather than only child Python processes. This is useful for testing PySys plugins.

New in version 2.0.