当前位置: 代码迷 >> python >> django-jenkins-AttributeError:“ Coverage”对象没有属性“ _harvest_data”
  详细解决方案

django-jenkins-AttributeError:“ Coverage”对象没有属性“ _harvest_data”

热度:115   发布时间:2023-06-13 14:04:47.0

我已经在以下环境中安装了django-jenkins

coverage (4.0.1)
Django (1.8)
pep8 (1.6.2)
django-jenkins (0.17.0)
pyflakes (1.0.0)

我尝试这个时

python manage.py jenkins --enable-coverage

我得到这个错误

Destroying test database for alias 'default'...
Storing coverage info...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django_jenkins/management/commands/jenkins.py", line 161, in handle
    coverage.save(tested_locations, options)
  File "/usr/local/lib/python2.7/dist-packages/django_jenkins/tasks/with_coverage.py", line 33, in save
    self.coverage.stop()
AttributeError: 'Coverage' object has no attribute '_harvest_data'

有任何想法吗 ? 我完全遵循了手册。

我发现django-jenkins使用Coverage,并且在最新版本的coverage中,方法_harvest_data已更改为get_data,但在django-jenkins的最终正式发行版中尚未使用,因此我切换到了其最新的git版本并解决了。