blob: 1fc5c10dbbefa877e8445649eb50d7ae390ad8cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
.. _plugins:
=======
Plugins
=======
.. :history: 20150124T143000, new page.
Coverage.py's behavior can be extended by writing plugins. A plugin is a
separately installed Python class that you register in your .coveragerc.
Plugins can be used to implement coverage measurement for non-Python files.
Using plugins
-------------
To use a coverage.py plugin, you install it, and configure it. For this
example, let's say you want to use one called fred_plugin.
#. Install the plugin as you would any other Python package::
pip install fred_plugin
#. Configure coverage.py to use the plugin. You do this by editing (or
creating) your .coveragerc file, as described in :ref:`config`. The
``plugins`` setting indicates your plugin::
[run]
plugins =
fred_plugin
#. If the plugin needs its own configuration, you can add those settings in
the .coveragerc file in a section named for the plugin::
[fred_plugin]
option1 = True
option2 = abc.foo
Check the documentation for the plugin to see if it takes any options, and
what they are.
#. Run your tests as you usually would. NOTE: You will see a warning when
coverage starts::
Coverage.py warning: Setting timid=True to support plugins.
This means that coverage will run slower than it usually would. This
limitation is part of the initial alpha release, it will be gone in the
final version.
Plugin API
----------
.. module:: coverage.plugin
.. autoclass:: CoveragePlugin
:members:
.. autoclass:: FileTracer
:members:
.. autoclass:: FileReporter
:members:
|