24

I've been using the following command to run tests and evaluate code coverage for a Python project for over a year now.

nosetests -v --with-coverage --cover-package=genhub genhub/*.py

The coverage report used to include a column on the far right showing the lines missing coverage.

Name                 Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------------
genhub/cdhit.py         50      0      8      0   100%   
genhub/exons.py         85     69      8      0    17%   24-40, 48-56, 60-79, 87-107, 129-132, 138-141, 147-150
genhub/fasta.py         76      0     26      0   100%   
genhub/genomedb.py     205    153     48      0    21%   40-43, 53-60, 64-65, 70, 74, 82, 86, 90, 98-99, 103-104, 108-109, 113-114, 118-119, 123-124, 128-129, 143-144, 152-154, 158-160, 164-166, 175, 180, 240-280, 289, 292, 295, 308-317, 323-330, 351-377, 380-386, 396-413, 419-430, 436-443, 449-456
genhub/iloci.py        112     91      8      0    18%   30-46, 54-64, 73-90, 102-118, 127-142, 165-173, 179-183, 189-193, 199-207, 213-225
genhub/mrnas.py        121    108     24      0     9%   30-63, 79-105, 118-158, 178-197, 203-226
genhub/pdom.py          95     68     24      0    23%   31-32, 35, 39, 43, 47, 50-53, 56-59, 62-64, 67-72, 75-106, 116-119, 126-128, 134-141, 148-156
genhub/proteins.py      20     13      2      0    32%   43-53, 94-97
genhub/refseq.py       237    195     44      0    15%   30-46, 49, 53, 57, 61, 65, 69, 73, 76-86, 89-115, 118-127, 130-178, 189-211, 217-226, 232-242, 248-265, 271-288, 294-297, 303-310, 317-326, 333-374, 380-387
genhub/registry.py     126     90     32      2    24%   48-56, 59-64, 67-69, 72-77, 81-83, 92-94, 103-109, 112-113, 116-117, 142-168, 174-188, 194-201, 207-216, 40->44, 44->48
genhub/stats.py          3      0      0      0   100%   
genhub/tair.py         128     97     22      0    21%   32-42, 45, 49, 53, 57, 61, 65, 69, 73, 76-79, 82-104, 110-119, 122-154, 165-180, 186-189, 195-203, 210-221
----------------------------------------------------------------
TOTAL                 1258    884    246      2    27%   
----------------------------------------------------------------------
Ran 46 tests in 0.033s

FAILED (errors=41)

However, the Missing column no longer shows up for me (nose version 1.3.7, coverage.py version 4.1).

I'm aware nose is no longer being supported. Is this change related to that, or something in coverage.py, or both?

Daniel Standage
  • 8,136
  • 19
  • 69
  • 116
  • See the **Note** here: https://nose.readthedocs.io/en/latest/plugins/cover.html. What was the previous "working" version you used? – Tom Myddeltyn Jun 09 '16 at 18:17
  • @busfault I know it was working with coverage.py 4.0.3. – Daniel Standage Jun 09 '16 at 18:20
  • I've got the same issue. I had `coverage==3.7.1` and `nose==1.3.7` and the line numbers were showing. `coverage==4.1` removed them. Time for me to revert. Please make an issue in their repo https://bitbucket.org/ned/coveragepy/issues/new – KFunk Jun 09 '16 at 23:12

3 Answers3

46

In coverage.py 4.1, I fixed a problem with the coverage.py API defaulting two parameters to non-None values. One of them was show_missing.

The best way to fix this in your project is to set show_missing in your .coveragerc file:

# .coveragerc
[report]
show_missing = True
Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
  • 8
    Is there a convenient way to set show_missing in the nose command rather than needing a .coveragerc? – Zeph Dec 12 '17 at 01:57
2

Beside having a configuration files to set show_missing you can also use coverage set_option to define it.

cov.set_option('report:show_missing', True)

I have issue with getting the correct coverage for models.py, i solve it according to this.

Then i just add the above lines to show missing line. So my manage.py have a part like this:

if is_testing:
    import coverage
    cov = coverage.coverage(source=['blog'], omit=['*/tests/*'])
    cov.set_option('report:show_missing', True) #add this
    cov.erase()
    cov.start()
Community
  • 1
  • 1
Zac Kwan
  • 5,587
  • 4
  • 20
  • 27
1

No need to revert back to 3.7.1 You can just downgrade to 4.0.0

Nitin Kr
  • 521
  • 2
  • 12