diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-06-14 09:41:01 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-06-14 09:41:01 -0400 |
commit | 18f7ecbc364a2e95def74d6e7546e920cc38e238 (patch) | |
tree | 14847e3605ea66246599404a2207be7549d32bca /coverage/plugin.py | |
parent | 6e5e9ae9d54e5fc1f4ac96c51344cb37c8ea3395 (diff) | |
download | python-coveragepy-18f7ecbc364a2e95def74d6e7546e920cc38e238.tar.gz |
Debugging plugin wrappers
Diffstat (limited to 'coverage/plugin.py')
-rw-r--r-- | coverage/plugin.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py index 6648d7a..3fbb43a 100644 --- a/coverage/plugin.py +++ b/coverage/plugin.py @@ -3,8 +3,10 @@ import os import re +from coverage import files from coverage.misc import _needs_to_implement + # TODO: document that the plugin objects may be decorated with attributes with # named "_coverage_*". @@ -25,7 +27,7 @@ class CoveragePlugin(object): """ - def __init__(self, options): + def __init__(self, options=None): """ When the plugin is constructed, it will be passed a dictionary of plugin-specific options read from the .coveragerc configuration file. @@ -36,7 +38,7 @@ class CoveragePlugin(object): .coveragerc configuration file. """ - self.options = options + self.options = options or {} def file_tracer(self, filename): # pylint: disable=unused-argument """Return a FileTracer object for a file. @@ -175,6 +177,9 @@ class FileReporter(object): " filename={self.filename!r}>".format(self=self) ) + def relative_filename(self): + return files.relative_filename(self.filename) + # Annoying comparison operators. Py3k wants __lt__ etc, and Py2k needs all # of them defined. @@ -247,6 +252,8 @@ class FileReporter(object): For example, the file a/b/c.py will return 'a_b_c_py' + You should not need to override this method. + """ - name = os.path.splitdrive(self.name)[1] + name = os.path.splitdrive(self.relative_filename())[1] return re.sub(r"[\\/.:]", "_", name) |