How to Fix Python Nose: Coverage not available: unable to import coverage module

PythonNosecoverage.pyPython Coverage

Python Problem Overview


I can't seem to get code coverage with Nose to work, despite having the plugin installed.

Any ideas on how to fix this?

12:15:25 ~/sandbox/ec$ nosetests --plugins
Plugin xunit
Plugin deprecated
Plugin skip
Plugin multiprocess
Plugin failuredetail
Plugin capture
Plugin logcapture
Plugin coverage
Plugin attributeselector
Plugin doctest
Plugin profile
Plugin id
Plugin allmodules
Plugin collect-only
Plugin isolation
Plugin pdb

12:15:34 ~/sandbox/ec$ nosetests -v --with-coverage
nose.plugins.cover: ERROR: Coverage not available: unable to import coverage module
tests.edgecast_client_tests.test_log ... ok

----------------------------------------------------------------------
Ran 1 test in 0.206s

OK

Python Solutions


Solution 1 - Python

Have you tried pip install coverage? The coverage plugin depends on separate coverage module, which is not a nose's dependency, so needs to be installed manually.

Solution 2 - Python

Validate if the coverage module is working by itself via coverage --version. I had a case that it was not working due to the lack of SQLite modules in my python installation from the source. I reinstalled python with SQLite extension to fix the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondoremiView Question on Stackoverflow
Solution 1 - PythonjkozeraView Answer on Stackoverflow
Solution 2 - PythonMarek OlszewskiView Answer on Stackoverflow