python - What constitutes a package for nosetests? -
i've written "package" -- mean directory __init__.py
in -- called ardid
:
(master)dbliss@nx3[ardid]> ls analysis.py ardid.sh __init__.pyc plot_support.py utils.py analysis.pyc goals.py k_12.png plot_support.pyc utils.pyc ardid.py goals.pyc plot_ardid.py results/ ardid.pyc __init__.py plot_ardid.pyc tests/
as can see, package contains following modules
analysis
ardid
goals
plot_ardid
plot_support
utils
as test modules in directory tests
.
(__init__.py
empty.)
however, when run nosetests
--cover-package=ardid
, output shows coverage few of ardid
's modules (specifically ardid
, goals
, , utils
):
(master)dbliss@nx3[ardid]> nosetests tests -s --cover-package=ardid --with-coverage ............... name stmts miss cover missing ---------------------------------------------- ardid.py 0 0 100% ardid/ardid.py 108 54 50% 105-254 ardid/goals.py 42 38 10% 52-87, 102-161 ardid/utils.py 437 366 16% 23-26, 30-71, 78, 83-89, 108-110, 113-140, 142-146, 165-166, 168-183, 186-218, 223-285, 288-324, 344, 357-427, 438-441, 443-444, 446-468, 475-480, 483-496, 499, 508-509, 512-513, 516-524, 532, 545-548, 559, 571, 575-576, 581-582, 594-605, 614-615, 618-1018 ---------------------------------------------- total 587 458 22% ---------------------------------------------------------------------- ran 15 tests in 11.454s ok
why this?
note not case these modules have tests:
(master)dbliss@nx3[ardid]> ls tests/ test_plot_support.py test_plot_support.pyc test_utils.py test_utils.pyc
what true ardid
module imports goals
, utils
, not import other modules. what's causing nosetests
detect goals
, utils
(in addition ardid
)? why be?
i think answer may have way i'm importing package modules in test modules. because ardid
module has same name package, have import with
from ardid import ardid
(if call simply
import ardid
the package imported.)
the other modules import with, e.g.,
import utils
nosetests
considers part of package ardid
modules imported ardid
(from ardid
package, not module).
thus, 1 simple solution change imports in test modules to
from ardid import x
where x
1 of modules tested.
another solution, more appropriate if package intended use other me (and subsumes solution), provided @jonrsharpe in comments.
Comments
Post a Comment