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 | 910c9db116f250fd1b26408e1d1eb52c4f3e2f0a (patch) | |
tree | 130a4dc479ec256a28f34974fa46580d0fc7198c /coverage/plugin.py | |
parent | 4dc7c52ffa20e9b8444f61092950618066f1a736 (diff) | |
download | python-coveragepy-git-910c9db116f250fd1b26408e1d1eb52c4f3e2f0a.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 6648d7a6..3fbb43aa 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) |