Skip to content

Commit

Permalink
Merge pull request #83 from ionelmc/master
Browse files Browse the repository at this point in the history
Fix support for coverage 4.0b1
  • Loading branch information
coagulant committed Aug 13, 2015
2 parents 67cbeac + 9821c93 commit 7f644f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 4 additions & 1 deletion coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def create_data(self, extra=None):
def get_coverage(self):
workman = coverage.coverage(config_file=self.config.get('config_file', True))
workman.load()
workman._harvest_data()
if hasattr(workman, '_harvest_data'):
workman._harvest_data()
else:
workman.get_data()
reporter = CoverallReporter(workman, workman.config)
return reporter.report()

Expand Down
17 changes: 12 additions & 5 deletions coveralls/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ def report(self, morfs=None):
`outfile` is a file object to write the json to.
"""
self.source_files = []
self.find_code_units(morfs)
if hasattr(self, 'find_code_units'):
self.find_code_units(morfs)
else:
self.find_file_reporters(morfs)

for cu in self.code_units:
units = self.code_units if hasattr(self, 'code_units') else self.file_reporters
for cu in units:
try:
self.parse_file(cu, self.coverage._analyze(cu))
except NoSource:
if not self.config.ignore_errors:
log.warn('No source for %s', cu.name)
log.warn('No source for %s', cu.filename)
except NotPython:
# Only report errors for .py files, and only if we didn't
# explicitly suppress those errors.
if cu.should_be_python() and not self.config.ignore_errors:
log.warn('Source file is not python %s', cu.name)
log.warn('Source file is not python %s', cu.filename)

return self.source_files

Expand Down Expand Up @@ -69,7 +73,10 @@ def parse_file(self, cu, analysis):
'Please check if encoding declaration is ok', basename(cu.filename))
return
else:
filename = analysis.coverage.file_locator.relative_filename(cu.filename)
if hasattr(cu, 'relative_filename'):
filename = cu.relative_filename()
else:
filename = analysis.coverage.file_locator.relative_filename(cu.filename)
source_lines = list(enumerate(analysis.file_reporter.source_token_lines()))
source = analysis.file_reporter.source()
coverage_lines = [self.get_hits(i, analysis) for i in range(1, len(source_lines) + 1)]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ deps =
sh
pyyaml: PyYAML>=3.10
cov3: coverage<4.0a0
cov4: coverage>=4.0a4
cov4: coverage>=4.0b1
commands = {posargs:{envpython} setup.py test}

0 comments on commit 7f644f1

Please sign in to comment.