鼻子测试覆盖权限错误

发布于 2024-10-28 01:52:38 字数 1711 浏览 5 评论 0原文

我今天开始使用鼻子测试,一切正常,直到我尝试:

nosetests --with-coverage --cover-html --cover-html-dir=/tmp/cache ,它会抛出权限被拒绝错误,我不明白为什么它试图写入标准库包:

Traceback (most recent call last):
  File "/usr/bin/nosetests", line 8, in <module>
    load_entry_point('nose==0.11.1', 'console_scripts', 'nosetests')()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 113, in __init__
    argv=argv, testRunner=testRunner, testLoader=testLoader)
  File "/usr/lib/python2.6/unittest.py", line 817, in __init__
    self.runTests()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 192, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 63, in run
    result.printErrors()
  File "/usr/lib/pymodules/python2.6/nose/result.py", line 88, in printErrors
    self.config.plugins.report(self.stream)
  File "/usr/lib/pymodules/python2.6/nose/plugins/manager.py", line 82, in __call__
    return self.call(*arg, **kw)
  File "/usr/lib/pymodules/python2.6/nose/plugins/manager.py", line 150, in simple
    result = meth(*arg, **kw)
  File "/usr/lib/pymodules/python2.6/nose/plugins/cover.py", line 168, in report
    coverage.annotate(files.values())
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 995, in annotate
    return the_coverage.annotate(*args, **kw)
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 906, in annotate
    self.annotate_file(filename, statements, excluded, missing, directory)
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 921, in annotate_file
    dest = open(dest_file, 'w')
IOError: [Errno 13] Permission denied: '/usr/lib/python2.6/email/iterators.py,cover'

I've started using nosetests today and everything works fine until I try:

nosetests --with-coverage --cover-html --cover-html-dir=/tmp/cache which throws a permission denied error and I don't understand why it's trying to write to standard library packages:

Traceback (most recent call last):
  File "/usr/bin/nosetests", line 8, in <module>
    load_entry_point('nose==0.11.1', 'console_scripts', 'nosetests')()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 113, in __init__
    argv=argv, testRunner=testRunner, testLoader=testLoader)
  File "/usr/lib/python2.6/unittest.py", line 817, in __init__
    self.runTests()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 192, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 63, in run
    result.printErrors()
  File "/usr/lib/pymodules/python2.6/nose/result.py", line 88, in printErrors
    self.config.plugins.report(self.stream)
  File "/usr/lib/pymodules/python2.6/nose/plugins/manager.py", line 82, in __call__
    return self.call(*arg, **kw)
  File "/usr/lib/pymodules/python2.6/nose/plugins/manager.py", line 150, in simple
    result = meth(*arg, **kw)
  File "/usr/lib/pymodules/python2.6/nose/plugins/cover.py", line 168, in report
    coverage.annotate(files.values())
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 995, in annotate
    return the_coverage.annotate(*args, **kw)
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 906, in annotate
    self.annotate_file(filename, statements, excluded, missing, directory)
  File "/usr/lib/python2.6/dist-packages/coverage.py", line 921, in annotate_file
    dest = open(dest_file, 'w')
IOError: [Errno 13] Permission denied: '/usr/lib/python2.6/email/iterators.py,cover'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别低头,皇冠会掉 2024-11-04 01:52:38

鼻子 --cover-html 开关已经过时了。如果你先运行nose,然后直接使用覆盖率生成HTML,你会对结果感到更满意:

$ nosetests --with-coverage
$ coverage html

然后打开htmlcov/index.html

The nose --cover-html switch is outdated. You'll be happier with the results if you run nose first, then use coverage directly to generate the HTML:

$ nosetests --with-coverage
$ coverage html

then open htmlcov/index.html

你怎么敢 2024-11-04 01:52:38

我发现我可以使用 --cover-package= 参数和我想要覆盖的包的名称。

I found that I could use the --cover-package= argument with the name of the package I wanted coverage for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文