Commit 083b8d94 authored by Stefan Behnel's avatar Stefan Behnel

adapt coverage plugin to new API in coverage.py 4.0a7, minor changes

parent 82aed5cd
...@@ -4,6 +4,8 @@ A Cython plugin for coverage.py ...@@ -4,6 +4,8 @@ A Cython plugin for coverage.py
Requires the coverage package at least in version 4.0 (which added the plugin API). Requires the coverage package at least in version 4.0 (which added the plugin API).
""" """
from __future__ import absolute_import
import re import re
import os.path import os.path
from collections import defaultdict from collections import defaultdict
...@@ -235,7 +237,7 @@ class CythonModuleTracer(FileTracer): ...@@ -235,7 +237,7 @@ class CythonModuleTracer(FileTracer):
pass pass
abs_path = os.path.abspath(source_file) abs_path = os.path.abspath(source_file)
if self.py_file and source_file.lower().endswith('.py'): if self.py_file and source_file[-3:].lower() == '.py':
# always let coverage.py handle this case itself # always let coverage.py handle this case itself
self._file_path_map[source_file] = self.py_file self._file_path_map[source_file] = self.py_file
return self.py_file return self.py_file
...@@ -286,3 +288,7 @@ class CythonModuleReporter(FileReporter): ...@@ -286,3 +288,7 @@ class CythonModuleReporter(FileReporter):
else: else:
for line in self._iter_source_tokens(): for line in self._iter_source_tokens():
yield [('txt', line)] yield [('txt', line)]
def coverage_init(reg, options):
reg.add_file_tracer(Plugin())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment