Romain$ sudo coverage run setup.py nosetests
----------------------------------------------------------------------
Ran 20 tests in 0.092s
OK
dhcp233-150:Operalib-2 Romain$ coverage report
Name Stmts Miss Cover Missing
---------------------------------------------------
operalib/Kernel.pyx 45 12 73% 10, 19, 32, 36, 40, 46, 49, 58, 68, 71, 75, 78
operalib/Model.pyx 31 16 48% 12, 20-27, 31, 35, 39, 43, 47, 51, 54-56
setup.py 10 0 100%
---------------------------------------------------
TOTAL 86 28 67%
[run]
plugins = Cython.Coverage
[report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
omit =
*test*
*/scipy/*
*/numpy/*
*/sklearn/*
*stringsource*
*/Python/*
*/python/*
*/site-packages/nose/*
*__init__*
show_missing = True
Q: Why do the bodies of functions (or classes) show as executed, but the def lines do not?
This happens because coverage is started after the functions are defined. The definition lines are executed without coverage measurement, then coverage is started, then the function is called. This means the body is measured, but the definition of the function itself is not.