如何让unittest2和coverage.py一起工作?
如何让 unittest2
和 coverage.py
一起工作?
理论上类似的东西
coverage run unit2 discover
应该可以工作,但目前它只是出错了。
如果您是 nose
用户,则相当于 nosetests --with-coverage
。
How can you get unittest2
and coverage.py
working together?
In theory something like
coverage run unit2 discover
should work, but it currently just errors out.
If you are a nose
user that will be the equivalent of nosetests --with-coverage
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试:
对我有用。
Try:
works for me.
这必须特定于您的安装,因为它对我来说可以很好地
生成覆盖范围信息,然后
生成 HTML 报告(几种报告格式之一)并
查看结果。
(回答这个问题是因为这是“unittest2 覆盖率”的首要问题,我不希望人们因缺乏任何答案而被推迟。)
This must be specific to your installation since it works fine for me
to generate the coverage information then
to generate the an HTML report (one of several reporting formats), and
to see the results.
(Answering this because this is a top ghit for "unittest2 coverage" and I don't want people put off by the lack of any answer.)
我正在运行 Windows 并遇到了同样的问题。
我怀疑这与不同操作系统上系统路径和Python路径处理方式的差异有关(我猜测Andrew正在运行Linux?)。无论如何,
coverage run
采用-m
选项,允许您运行模块而不是脚本。这就是我使用的:I am running Windows and encountered the same problem.
I suspect this is related to differences in how the system path and python path are handled on various operating systems (I'm guessing Andrew is running linux?). Regardless,
coverage run
takes a-m
option which allows you to run a module rather than a script. This is what I use:如果您安装了多个版本的
coverage
,请使用或
指定要运行哪个版本。
In case you have multiple versions of
coverage
installed, useor
to specify which one you're going to run.