When I test https://bitbucket.org/petar/beam_integrals with python setup.py nosetests
I get a 96% coverage:
----------------------------------------------------------------------
XML: nosetests.xml
Name Stmts Miss Cover Missing
------------------------------------------------------------------------------
beam_integrals 7 7 0% 1-24
beam_integrals.beam_types 79 0 100%
beam_integrals.characteristic_equation_solvers 65 0 100%
beam_integrals.exceptions 6 0 100%
beam_integrals.utils 14 0 100%
------------------------------------------------------------------------------
TOTAL 171 7 96%
----------------------------------------------------------------------
Ran 634 tests in 178.245s
OK (SKIP=3)
However if I test the same code with nosetests
I get full coverage:
----------------------------------------------------------------------
XML: nosetests.xml
Name Stmts Miss Cover Missing
------------------------------------------------------------------------------
beam_integrals 7 0 100%
beam_integrals.beam_types 79 0 100%
beam_integrals.characteristic_equation_solvers 65 0 100%
beam_integrals.exceptions 6 0 100%
beam_integrals.utils 14 0 100%
------------------------------------------------------------------------------
TOTAL 171 0 100%
----------------------------------------------------------------------
Ran 634 tests in 179.226s
OK (SKIP=3)
It seems python setup.py nosetests
isn't properly reporting test coverage of the beam_integrals
module.
This issue has been verified on:
a freshly created Rackspace Cloud Server running Ubuntu 12.04 Server 64bit with the following setup:
$ sudo aptitude update
$ sudo aptitude upgrade
$ sudo reboot
$ sudo aptitude install python-pip mercurial git-core python-gmpy python-dev
$ hg clone https://bitbucket.org/petar/beam_integrals
$ sudo pip install -r beam_integrals/requirements.txt
$ sudo pip install -r beam_integrals/requirements-test.txt
$ cd beam_integrals
$ python setup.py nosetests
$ nosetests
python setup.py nosetests
is importing beam_integrals before starting coverage testing, so it's already been imported when coverage measurement is happening. This is because your setup.py imports beam_integrals directly. This isn't a bad thing to do, lots of Python projects do this to get version information from the code itself rather than duplicating it in the setup.py.
When you use nosetests
, it knows to begin the coverage measurement before importing anything. Actually, it probably imports things, unimports them, starts coverage, then runs the code, which imports things again.
I'm not sure what you can do about this, other than to use nosetests
to run your tests.