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 /tests/plugin_config.py | |
parent | 62a47468147c97379ea106b3f9c994445b4a08a4 (diff) | |
download | python-coveragepy-git-62699a318754c6811622d31cfab195b4dbc3775e.tar.gz |
A new kind of plug-in: configurers. #563
Diffstat (limited to 'tests/plugin_config.py')
-rw-r--r-- | tests/plugin_config.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/plugin_config.py b/tests/plugin_config.py new file mode 100644 index 00000000..67a790a2 --- /dev/null +++ b/tests/plugin_config.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt + +"""A configuring plugin for test_plugins.py to import.""" + +import coverage + + +class Plugin(coverage.CoveragePlugin): + """A configuring plugin for testing.""" + def configure(self, config): + """Configure all the things!""" + opt_name = "report:exclude_lines" + exclude_lines = config.get_option(opt_name) + exclude_lines.append(r"pragma: custom") + exclude_lines.append(r"pragma: or whatever") + config.set_option(opt_name, exclude_lines) + + +def coverage_init(reg, options): # pylint: disable=unused-argument + """Called by coverage to initialize the plugins here.""" + reg.add_configurer(Plugin()) |