鼻子.plugins.cover:错误:覆盖范围不可用:无法导入覆盖模块

时间:2018-08-03 10:07:03

标签: python nose coverage.py

在尝试计算python项目的覆盖率时,遇到以下错误:

nose.plugins.xcover: ERROR: Coverage not available: unable to import coverage module

这是我正在运行的命令:

nosetests --verbosity=3 --with-xcoverage --cover-package=mypackage--nocapture --nologcapture --with-xunit --cover-inclusive

我不知道为什么会出错,我安装了coverage软件包,nosetests具有覆盖率和xcoverage的两个插件。

这是pip freeze的输出:

certifi==2018.4.16
chardet==3.0.4
coverage==4.5.1
fasteners==0.14.1
idna==2.7
jenkins-job-builder==2.2.1
jenkinsapi==0.3.6
Jinja2==2.10
MarkupSafe==1.0
monotonic==1.5
multi-key-dict==2.0.3
nose==1.3.7
nosexcover==1.0.11
pbr==4.2.0
psutil==5.4.6
python-jenkins==1.1.0
pytz==2018.5
PyYAML==3.13
requests==2.19.1
six==1.11.0
stevedore==1.29.0
tornado==5.1
urllib3==1.23
websocket-client==0.48.0

还有nosetests --plugins的输出:

Plugin capture
Plugin failuredetail
Plugin xunit
Plugin deprecated
Plugin skip
Plugin multiprocess
Plugin logcapture
Plugin xcoverage
Plugin coverage
Plugin attributeselector
Plugin doctest
Plugin profile
Plugin id
Plugin allmodules
Plugin collect-only
Plugin isolation
Plugin pdb

我正在Windows 10上使用Python 3.7.0

1 个答案:

答案 0 :(得分:0)

您的pip命令很可能安装在与nosetest不同的Python中。尝试使用python -m pippython -m nose.main,以便所有内容都来自同一安装。