html report and package name vs (module) file (absolute) path : question

Issue #520 closed
Gregory Starck created an issue

Hi,

I have this situation / structure:

my_project/
    setup.py
    my_pkg/
    my_pkg/__init__.py  # obviously
    my_pkg/a
    my_pkg/a/__init__.py
    my_pkg/a/b.py
    my_pkg/c.py
    etc...

(actually my_pkg is deeper below my_project, under a kind of "src" directory but this doesn't change anything)

I'm trying to get coverage to output / generate html with "package names" for my_pkg ; that is I'm trying to get:

Name                                     Stmts   Miss  Cove
my_pkg   :      1234 234     30% 
my_pkg.a    :   etc xx% lines 
my_pkg.a.b   :   etc 
# etc.. 

but if I normally pip install my package, then what I get is:

Name                                     Stmts   Miss  Cove
/abs_path_to_python_site_package/my_pkg/__init__.py  :   1234 234  30%
/abs_path_to_python_site_package/my_pkg/a.py

that is : how to get the package/module name instead of (absolute) file paths in the html report, as I ?

at the best I can eventually get relative paths to the files in case I test "in place" but isn't it possible to get the package/module (dotted) names instead ?

I searched the docs, stackoverflow, googled anything I could but I don't find.

thx.

Comments (2)

  1. Loic Dachary

    I don't think there is a way to get dotted package names instead of a path. It would be tricky because. my_pkg/init.py would have to be my_pkg. But when reading my_pkg in the results, it's unclear if that is my_pkg.py or my_pkg/init.py. And it's non trivial to figure out in which directory of PYTHONPATH it is located. I can't figure out a way to display that so it looks pretty and non confusing. Any ideas ?

  2. Log in to comment