diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-01-06 17:06:59 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-01-06 17:06:59 -0500 |
commit | 62699a318754c6811622d31cfab195b4dbc3775e (patch) | |
tree | 43771e501b7e5d8c4d9147517c46234726e1fc54 /coverage/control.py | |
parent | 62a47468147c97379ea106b3f9c994445b4a08a4 (diff) | |
download | python-coveragepy-git-62699a318754c6811622d31cfab195b4dbc3775e.tar.gz |
A new kind of plug-in: configurers. #563
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/coverage/control.py b/coverage/control.py index fdcb544e..f1db1ef7 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -11,6 +11,7 @@ import os import platform import re import sys +import time import traceback from coverage import env @@ -216,14 +217,22 @@ class Coverage(object): self._debug_file = sys.stderr self.debug = DebugControl(self.config.debug, self._debug_file) - # Load plugins - self.plugins = Plugins.load_plugins(self.config.plugins, self.config, self.debug) - # _exclude_re is a dict that maps exclusion list names to compiled regexes. self._exclude_re = {} set_relative_directory() + # Load plugins + self.plugins = Plugins.load_plugins(self.config.plugins, self.config, self.debug) + + # Run configuring plugins. + for plugin in self.plugins.configurers: + # We need an object with set_option and get_option. Either self or + # self.config will do. Choosing randomly stops people from doing + # other things with those objects, against the public API. Yes, + # this is a bit childish. :) + plugin.configure([self, self.config][int(time.time()) % 2]) + # The source argument can be directories or package names. self.source = [] self.source_pkgs = [] @@ -507,7 +516,7 @@ class Coverage(object): break except Exception: self._warn( - "Disabling plugin %r due to an exception:" % ( + "Disabling plug-in %r due to an exception:" % ( plugin._coverage_plugin_name ) ) @@ -639,8 +648,8 @@ class Coverage(object): option name. For example, the ``branch`` option in the ``[run]`` section of the config file would be indicated with ``"run:branch"``. - `value` is the new value for the option. This should be a Python - value where appropriate. For example, use True for booleans, not the + `value` is the new value for the option. This should be an + appropriate Python value. For example, use True for booleans, not the string ``"True"``. As an example, calling:: |