Python 鼻子测试覆盖权限错误

Python 鼻子测试覆盖权限错误,python,code-coverage,nosetests,Python,Code Coverage,Nosetests,我今天开始使用鼻测试,在我尝试之前,一切都正常: 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', '

我今天开始使用鼻测试,在我尝试之前,一切都正常:

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'
回溯(最近一次呼叫最后一次):
文件“/usr/bin/nosetests”,第8行,在
加载入口点(“nose==0.11.1”,“控制台脚本”,“nosetests”)()
文件“/usr/lib/pymodules/python2.6/nose/core.py”,第113行,在__
argv=argv,testRunner=testRunner,testLoader=testLoader)
文件“/usr/lib/python2.6/unittest.py”,第817行,在__
self.runTests()
runTests中的文件“/usr/lib/pymodules/python2.6/nose/core.py”,第192行
结果=self.testRunner.run(self.test)
文件“/usr/lib/pymodules/python2.6/nose/core.py”,第63行,运行中
result.printErrors()
文件“/usr/lib/pymodules/python2.6/nose/result.py”,第88行,在printErrors中
self.config.plugins.report(self.stream)
文件“/usr/lib/pymodules/python2.6/nose/plugins/manager.py”,第82行,在调用中__
返回自呼叫(*arg,**kw)
文件“/usr/lib/pymodules/python2.6/nose/plugins/manager.py”,第150行,简单格式
结果=方法(*参数,**kw)
文件“/usr/lib/pymodules/python2.6/nose/plugins/cover.py”,报告第168行
coverage.annotate(files.values())
文件“/usr/lib/python2.6/dist-packages/coverage.py”,第995行,注释中
返回_覆盖率。注释(*args,**kw)
文件“/usr/lib/python2.6/dist-packages/coverage.py”,第906行,注释中
self.annotate_文件(文件名、语句、已排除、缺少、目录)
文件“/usr/lib/python2.6/dist packages/coverage.py”,第921行,在注释_文件中
dest=打开(dest\u文件“w”)
IOError:[Errno 13]权限被拒绝:'/usr/lib/python2.6/email/iterators.py,cover'
nose
--cover html
开关已过时。如果您先运行nose,然后直接使用coverage生成HTML,您会对结果更满意:

$ nosetests --with-coverage
$ coverage html
然后打开htmlcov/index.html

nose
--cover html
开关已过时。如果您先运行nose,然后直接使用coverage生成HTML,您会对结果更满意:

$ nosetests --with-coverage
$ coverage html

然后打开htmlcov/index.html

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

我发现我可以将
--cover package=
参数与我想要覆盖的包的名称一起使用