2013-01-23 29 views
47

儘管安裝了插件,但似乎無法使用鼻子獲得代碼覆蓋率。如何修復Python鼻子:覆蓋率不可用:無法導入覆蓋率模塊

有關如何解決此問題的任何想法?

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 

回答

80

您試過pip install coverage?覆蓋率插件取決於單獨的覆蓋率模塊,這不是鼻子的依賴性,因此需要手動安裝。

+3

在debian/ubuntu上,你可以通過'apt-get install python-coverage'安裝 – mnagel

+2

我已經安裝了它,它仍然給我同樣的錯誤。 –

+3

即使我在virtualenv中安裝了覆蓋包,我仍然在原始問題中收到同樣的錯誤。我的問題是nosetests命令來自我的系統範圍的鼻子安裝,而且我沒有在系統範圍內安裝覆蓋範圍。通過在我的virtualenv中加入可執行文件的完整路徑,/ path/to/virtualenv/bin/nosetests --with-coverage起作用。 – velotron