[TIP] Using coverage from API and command line gives different results
Alexander Todorov
atodorov at redhat.com
Tue Feb 11 08:50:41 PST 2014
Hello folks,
I'm fairly new to coverage but I've noticed something strange. With the sample
Python scripts (attached) which include modules I see the following:
If starting coverage from its API the report says:
# ./myprog
Hello __main__
Hello mymodule1
Hello mymodule2
# coverage report
Name Stmts Miss Cover
-------------------------------
mymodule1 2 0 100%
mymodule2 2 0 100%
-------------------------------
TOTAL 4 0 100%
If starting coverage from the command line:
# coverage run ./myprog2
Hello __main__
Hello mymodule1
Hello mymodule2
# coverage report
Name Stmts Miss Cover
-------------------------------
mymodule1 2 0 100%
mymodule2 2 0 100%
myprog2 5 0 100%
-------------------------------
TOTAL 9 0 100%
The difference as seen is that the main program file is not reported. On a
larger project I'm trying to integrate coverage with I see exactly the opposite
- the main program file is included in the report while the modules it includes
are not (not all of them). All modules are in site-packages.
This is with coverage-3.7 on Fedora 20.
Any ideas or comments ? Is this a known issue or a bug?
Regards,
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coverage_run.coverage
Type: application/octet-stream
Size: 188 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140211/b80b6b52/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exec_from_api.coverage
Type: application/octet-stream
Size: 142 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140211/b80b6b52/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mymodule1.py
Type: text/x-python
Size: 41 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140211/b80b6b52/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mymodule2.py
Type: text/x-python
Size: 41 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140211/b80b6b52/attachment-0001.py>
-------------- next part --------------
#!/usr/bin/env python
import coverage
cov = coverage.coverage()
cov.start()
import mymodule1
from mymodule2 import hello as hello2
print "Hello", __name__
mymodule1.hello()
hello2()
cov.stop()
cov.save()
-------------- next part --------------
#!/usr/bin/env python
import mymodule1
from mymodule2 import hello as hello2
print "Hello", __name__
mymodule1.hello()
hello2()
More information about the testing-in-python
mailing list