From 152d22cfbae8a8371acabe35ae3de61fb31708d3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 5 Jul 2015 11:07:11 -0400 Subject: Change how plugins are initialized. No more Plugin. Now coverage_init. --- tests/plugin2.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/plugin2.py') diff --git a/tests/plugin2.py b/tests/plugin2.py index 70d2524..9c3cb1d 100644 --- a/tests/plugin2.py +++ b/tests/plugin2.py @@ -4,10 +4,9 @@ import os.path import coverage -# pylint: disable=missing-docstring - class Plugin(coverage.CoveragePlugin): + """A plugin for testing.""" def file_tracer(self, filename): if "render.py" in filename: return RenderFileTracer() @@ -34,8 +33,14 @@ class RenderFileTracer(coverage.plugin.FileTracer): class FileReporter(coverage.plugin.FileReporter): + """A goofy file reporter.""" def statements(self): # Goofy test arrangement: claim that the file has as many lines as the # number in its name. num = os.path.basename(self.filename).split(".")[0].split("_")[1] return set(range(1, int(num)+1)) + + +def coverage_init(reg, options): + """Called by coverage to initialize the plugins here.""" + reg.add_file_tracer(Plugin(options)) -- cgit v1.2.1