5 |
5 |
6 import os |
6 import os |
7 import os.path |
7 import os.path |
8 import sys |
8 import sys |
9 |
9 |
10 from coverage.exceptions import CoverageException |
10 from coverage.exceptions import PluginError |
11 from coverage.misc import isolate_module |
11 from coverage.misc import isolate_module |
12 from coverage.plugin import CoveragePlugin, FileTracer, FileReporter |
12 from coverage.plugin import CoveragePlugin, FileTracer, FileReporter |
13 |
13 |
14 os = isolate_module(os) |
14 os = isolate_module(os) |
15 |
15 |
42 __import__(module) |
42 __import__(module) |
43 mod = sys.modules[module] |
43 mod = sys.modules[module] |
44 |
44 |
45 coverage_init = getattr(mod, "coverage_init", None) |
45 coverage_init = getattr(mod, "coverage_init", None) |
46 if not coverage_init: |
46 if not coverage_init: |
47 raise CoverageException( |
47 raise PluginError( |
48 f"Plugin module {module!r} didn't define a coverage_init function" |
48 f"Plugin module {module!r} didn't define a coverage_init function" |
49 ) |
49 ) |
50 |
50 |
51 options = config.get_plugin_options(module) |
51 options = config.get_plugin_options(module) |
52 coverage_init(plugins, options) |
52 coverage_init(plugins, options) |
108 self.order.append(plugin) |
108 self.order.append(plugin) |
109 self.names[plugin_name] = plugin |
109 self.names[plugin_name] = plugin |
110 if specialized is not None: |
110 if specialized is not None: |
111 specialized.append(plugin) |
111 specialized.append(plugin) |
112 |
112 |
113 def __nonzero__(self): |
113 def __bool__(self): |
114 return bool(self.order) |
114 return bool(self.order) |
115 |
|
116 __bool__ = __nonzero__ |
|
117 |
115 |
118 def __iter__(self): |
116 def __iter__(self): |
119 return iter(self.order) |
117 return iter(self.order) |
120 |
118 |
121 def get(self, plugin_name): |
119 def get(self, plugin_name): |