No coverage in IDE, but coveragepy shows 46% coverage

40 Views Asked by At

I'm trying to get code coverage metrics in my IDE, but I can't seem to get the coverage to show right. It always shows up as no coverage.

I am using the following in ~/.vim/ftplugin/ale.vim:

Plug 'mgedmin/coverage-highlight.vim'
Plug 'dense-analysis/ale'
Plug 'tpope/vim-sensible'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'davidhalter/jedi-vim'
call plug#end()

I can clone my github project and run tests. My coverage report shows 46% coverage:

$ coverage report
Name                                           Stmts   Miss  Cover
------------------------------------------------------------------
/home/dwenjii/pmlib/pmlib/__init__.py       0      0   100%
/home/dwenjii/pmlib/pmlib/task.py         154     92    40%
test_pmlib.py                                     16      0   100%
------------------------------------------------------------------
TOTAL                                            170     92    46%

As you can see, that's 46% coverage, but mgedmin/coverage-highlight.vim shows no red when I execute :HighlightCoverage.

I have the following versions:

attrs == 23.1.0
loguru == 0.7.2
tasklib == 2.5.1
texttable == 1.7.0
matplotlib == 3.8.2
coverage == 7.3.2
pytest == 7.4.3

How do I fix this problem so I show the real uncovered lines in my IDE?

1

There are 1 best solutions below

1
Mike Pennington On

I think your problem is that your .coverage sqllite coverage report is not in your base git directory. In this case, it's in /home/dwenjii/pmlib/tests/.coverage, but it needs to be in /home/dwenjii/pmlib/.coverage.

If you don't have .coverage in your base git directory, then mgedmin/coverage-highlight.vim won't see any coverage metrics (even if .coverage is in tests/).