1

I am using django-jenkins v0.110.0 and coverage v5.2.1 , with Django v3.1. As mentioned in the subject, when I ran:

python manage.py jenkins --enable-coverage

I get this error:

AttributeError: 'Coverage' object has no attribute 'data'

Below is the entire stack traceback:

Traceback (most recent call last):
  File "manage.py", line 16, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django_jenkins/management/commands/jenkins.py", line 47, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django_jenkins/management/commands/jenkins.py", line 116, in handle
    coverage.save(tested_locations, options)
  File "/usr/local/lib/python3.8/site-packages/django_jenkins/tasks/with_coverage.py", line 29, in save
    self.coverage.stop()
  File "/usr/local/lib/python3.8/site-packages/django_jenkins/tasks/with_coverage.py", line 55, in get_morfs
    return [filename for filename in coverage.data.measured_files()
AttributeError: 'Coverage' object has no attribute 'data'

Test methods in tests.py were ran properly, and junit.xml was produced under the reports dir. But no coverage reports, definitely, because of this error. Am I missing something here? Should I specify a coverage configuration file (coverage.rc) for it to work? Is it not compatible with python3.8? Other issues?

Any ideas are greatly appreciated. Thanks in advance!

jaysonpryde
  • 2,733
  • 11
  • 44
  • 61

2 Answers2

2

This is late, but in case anyone else is facing this issue when using django-jenkins and coverage. I managed to get it working again by using coverage==4.3.4. I did this because from django-jenkins github I saw that they are using this version of coverage.

pooh mok
  • 21
  • 3
1

You have a dependency problem. django-jenkins latest release was in september 2016. django v3 was released in september 2019. You would have to downgrade django to a release from that period in time.

I strongly advice you to not solve this problem but rather select a different solution other than django-jenkins.

Personally, I use tox so I can deploy my testing and tooling on any ci/cd tooling combined with calling coverage/pytest and any and all tooling (black, mypy, safety, flake8 etc) directly. Wrapper libraries such as django-jenkins are simply too unreliable or make features unaccessible due to wrapping. Take my tox.ini if you need an advanced start.

Good luck.

Shine
  • 676
  • 6
  • 12