Many 'Coverage.py warning: Module XXX was previously imported, but not measured.'

Issue #532 invalid
mohierf created an issue

I do not understand why I get many Coverage.py warning: Module alignak was previously imported, but not measured. when I run my test suite on Travis.

I am runninng coverage as a plugin of the nose module with this command:

# Delete previously existing coverage results
coverage erase

# Run all the unit tests
nosetests -xv --process-restartworker --processes=1 --process-timeout=300  --with-coverage --cover-package=alignak

# Combine coverage files
coverage combine

Despite all the warning message, my current coverage report is almost 75% !

With the same test suite, If I run:

coverage run --source=alignak --rcfile=.coveragerc -m nose -c .noserc

my coverage report is no more than 19% !

I think there is something quite strange in this build ... should you explain where I make a mistake? Thanks

Comments (8)

  1. Ned Batchelder repo owner

    Maybe I'm going blind, but I can't find that warning in the Travis logs there....

  2. mohierf reporter

    What I noticed is that I get a Coverage.py warning: Module alignak was previously imported, but not measured. for each test function in a test Class ... this only when coverage is a plugin of nose.

    I do not have any of those warnings when I run nose as a module from coverage, but my coverage report drastically decrease :/

  3. Ned Batchelder repo owner

    I can reproduce the warnings here, but I don't understand why they happen. I'm guessing it has to do with how the nose multiprocessing plugin works. Are you committed to nose? It's currently unmaintained, so at least nose2, or even better, pytest would be a better option. Why are you using --processes=1? Doesn't that negate the benefit of multiprocessing?

  4. mohierf reporter

    Thanks Ned for your advise and support. I made some tests with nose2 and py.tests today and it clearly improves my tests suite ! I will migrate everything to py.test which seems really quite better for my tests and that provide a better code coverage report than nose !

  5. Log in to comment