Skip to content

Commit 3b3bc7a

Browse files
nedbatjambonrose
authored andcommitted
Add compatibility for Coverage 5
Now works with both coverage 4.x and 5.x PR #66
1 parent 46084a2 commit 3b3bc7a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Supported Python versions: 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8.
3030

3131
Supported Django versions: 1.8, 1.11, 2.0, 2.1, 2.2 and 3.0.
3232

33-
Supported coverage.py version 4.x . Support for version 5 is on the way!
33+
Supported coverage.py version 4.x or 5.x.
3434

3535
The plugin is pip installable::
3636

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def read(*names, **kwargs):
6767
url='https://github.com/nedbat/django_coverage_plugin',
6868
packages=['django_coverage_plugin'],
6969
install_requires=[
70-
'coverage >= 4.0 , < 5',
70+
'coverage',
7171
'six >= 1.4.0',
7272
],
7373
license='Apache 2.0',

tests/plugin_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ def run_django_coverage(
136136
self.cov.stop()
137137
self.cov.save()
138138
# Warning! Accessing secret internals!
139-
for pl in self.cov.plugins:
139+
if hasattr(self.cov, 'plugins'):
140+
plugins = self.cov.plugins
141+
else:
142+
plugins = self.cov._plugins
143+
for pl in plugins:
140144
if isinstance(pl, DjangoTemplatePlugin):
141145
if not pl._coverage_enabled:
142146
raise PluginDisabled()
@@ -174,7 +178,7 @@ def get_analysis(self, name=None):
174178

175179
def measured_files(self):
176180
"""Get the list of measured files, in relative form."""
177-
return [os.path.relpath(f) for f in self.cov.data.measured_files()]
181+
return [os.path.relpath(f) for f in self.cov.get_data().measured_files()]
178182

179183
def assert_analysis(self, executable, missing=None, name=None):
180184
"""Assert that the analysis for `name` is right."""

0 commit comments

Comments
 (0)