如何修复Python Nose:覆盖范围不可用:无法导入coverage模块

dor*_*emi 52 python nose coverage.py python-coverage

尽管安装了插件,我似乎无法使用Nose进行代码覆盖.

有想法该怎么解决这个吗?

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
Run Code Online (Sandbox Code Playgroud)

jko*_*era 87

你试过pip install coverage吗?coverage插件依赖于单独的coverage模块,它不是鼻子的依赖,因此需要手动安装.

  • 在debian/ubuntu上你也可以通过`apt-get install python-coverage`安装 (3认同)
  • 即使我在virtualenv中安装了coverage软件包,我在原始问题中也收到了同样的错误.我的问题是nosetests命令来自我的系统范围的鼻子安装,我没有在系统范围内安装覆盖.通过在virtualenv中预先填充可执行文件的完整路径,/ path/to/virtualenv/bin/nosetests --with-coverage工作. (3认同)
  • 我已经两种方式安装它仍然给我同样的错误. (2认同)
  • @mnagel @Diego 如果你有 Python3,你可能需要使用 `apt-get install python3-coverage`。 (2认同)