[SciPy-Dev] Measuring test coverage of a Cython module
Ralf Gommers
ralf.gommers at gmail.com
Wed Mar 28 00:06:15 EDT 2018
On Mon, Mar 26, 2018 at 11:11 AM, Lars G. <lagru at mailbox.org> wrote:
> Hi,
> I'm trying to measure the test coverage of a Cython module. However the
> module in question (`scipy/signal/peak_finding_utils.pyx`) doesn't show
> up in the final report.
>
> What I have tried so far:
>
> 1. Added `plugins = Cython.coverage` to the `.coveragerc` file.
>
> 2. Added
> # cython: linetrace=True
> # distutils: define_macros=CYTHON_TRACE_NOGIL=1
> to the header of `peak_finding_utils.pyx`
>
> 3. Build binaries inplace with
> $ python setup.py build_ext --inplace
>
> 4. Measured test coverage
> a) with `runtests.py`
> $ python runtests.py -t scipy/signal/tests/test_peak_finding --no-build
> --coverage
>
> b) and using the `coverage` package
> $ coverage run -m pytest scipy/signal/tests/test_peak_finding.py
> $ coverage html
>
The one step missing here seems to be editing .coveragerc:
http://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html?highlight=coverage#enabling-coverage-analysis
>
> This approach is based on this blog post:
> http://blog.behnel.de/posts/coverage-analysis-for-cython-modules.html
>
> In both cases a) and b) the PYX file sadly isn't included in the report
> and I don't know what to try next. Has anyone figured out a way to do
> this? If I've overlooked a related issue or conversation on the mailing
> list I apologize and would be grateful if you could point me to it.
>
The only discussion I remember is one on the scikit-image list started by
Matthew Brett to get this working; not sure if that came to anything. In
general it looks like it should work, but it isn't always reliable (e.g.
https://github.com/cython/cython/issues/1985)
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180327/951130ee/attachment.html>
More information about the SciPy-Dev
mailing list