OLD | NEW |
1 .. _config: | 1 .. _config: |
2 | 2 |
3 =================== | 3 =================== |
4 Configuration files | 4 Configuration files |
5 =================== | 5 =================== |
6 | 6 |
7 :history: 20100223T201600, new for 3.3 | 7 :history: 20100223T201600, new for 3.3 |
8 :history: 20100725T211700, updated for 3.4. | 8 :history: 20100725T211700, updated for 3.4. |
9 :history: 20100824T092900, added ``precision``. | 9 :history: 20100824T092900, added ``precision``. |
10 :history: 20110604T184400, updated for 3.5. | 10 :history: 20110604T184400, updated for 3.5. |
11 :history: 20110827T212700, updated for 3.5.1 | 11 :history: 20110827T212700, updated for 3.5.1 |
| 12 :history: 20130926T222300, updated for 3.6.1 |
12 | 13 |
13 | 14 |
14 Coverage.py options can be specified in a configuration file. This makes it | 15 Coverage.py options can be specified in a configuration file. This makes it |
15 easier to re-run coverage with consistent settings, and also allows for | 16 easier to re-run coverage with consistent settings, and also allows for |
16 specification of options that are otherwise only available in the | 17 specification of options that are otherwise only available in the |
17 :ref:`API <api>`. | 18 :ref:`API <api>`. |
18 | 19 |
19 Configuration files also make it easier to get coverage testing of spawned | 20 Configuration files also make it easier to get coverage testing of spawned |
20 sub-processes. See :ref:`subprocess` for more details. | 21 sub-processes. See :ref:`subprocess` for more details. |
21 | 22 |
22 The default name for configuration files is ``.coveragerc``, in the same | 23 The default name for configuration files is ``.coveragerc``, in the same |
23 directory coverage.py is being run in. Most of the settings in the | 24 directory coverage.py is being run in. Most of the settings in the |
24 configuration file are tied to your source code and how it should be | 25 configuration file are tied to your source code and how it should be measured, |
25 measured, so it should be stored with your source, and checked into | 26 so it should be stored with your source, and checked into source control, |
26 source control, rather than put in your home directory. | 27 rather than put in your home directory. |
27 | 28 |
28 | 29 |
29 Syntax | 30 Syntax |
30 ------ | 31 ------ |
31 | 32 |
32 A coverage.py configuration file is in classic .ini file format: sections are | 33 A coverage.py configuration file is in classic .ini file format: sections are |
33 introduced by a ``[section]`` header, and contain ``name = value`` entries. | 34 introduced by a ``[section]`` header, and contain ``name = value`` entries. |
34 Lines beginning with ``#`` or ``;`` are ignored as comments. | 35 Lines beginning with ``#`` or ``;`` are ignored as comments. |
35 | 36 |
36 Strings don't need quotes. Multi-valued strings can be created by indenting | 37 Strings don't need quotes. Multi-valued strings can be created by indenting |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 ``branch`` (boolean, default False): whether to measure | 87 ``branch`` (boolean, default False): whether to measure |
87 :ref:`branch coverage <branch>` in addition to statement coverage. | 88 :ref:`branch coverage <branch>` in addition to statement coverage. |
88 | 89 |
89 ``cover_pylib`` (boolean, default False): whether to measure the Python | 90 ``cover_pylib`` (boolean, default False): whether to measure the Python |
90 standard library. | 91 standard library. |
91 | 92 |
92 ``data_file`` (string, default ".coverage"): the name of the data file to use | 93 ``data_file`` (string, default ".coverage"): the name of the data file to use |
93 for storing or reporting coverage. | 94 for storing or reporting coverage. |
94 | 95 |
| 96 ``debug`` (multi-string): a list of debug options. See :ref:`the run |
| 97 --debug option <cmd_run_debug>` for details. |
| 98 |
95 ``include`` (multi-string): a list of filename patterns, the files to include | 99 ``include`` (multi-string): a list of filename patterns, the files to include |
96 in measurement or reporting. See :ref:`source` for details. | 100 in measurement or reporting. See :ref:`source` for details. |
97 | 101 |
98 ``omit`` (multi-string): a list of filename patterns, the files to leave out | 102 ``omit`` (multi-string): a list of filename patterns, the files to leave out |
99 of measurement or reporting. See :ref:`source` for details. | 103 of measurement or reporting. See :ref:`source` for details. |
100 | 104 |
101 ``parallel`` (boolean, default False): append the machine name, process | 105 ``parallel`` (boolean, default False): append the machine name, process |
102 id and random number to the data file name to simplify collecting data from | 106 id and random number to the data file name to simplify collecting data from |
103 many processes. See :ref:`cmd_combining` for more information. | 107 many processes. See :ref:`cmd_combining` for more information. |
104 | 108 |
105 ``source`` (multi-string): a list of packages or directories, the source to | 109 ``source`` (multi-string): a list of packages or directories, the source to |
106 measure during execution. See :ref:`source` for details. | 110 measure during execution. See :ref:`source` for details. |
107 | 111 |
108 ``timid`` (boolean, default False): use a simpler but slower trace method. | 112 ``timid`` (boolean, default False): use a simpler but slower trace method. |
109 Try this if you get seemingly impossible results. | 113 Try this if you get seemingly impossible results. |
110 | 114 |
111 | 115 |
112 .. _config_paths: | 116 .. _config_paths: |
113 | 117 |
114 [paths] | 118 [paths] |
115 ------- | 119 ------- |
116 | 120 |
117 The entries in this section are lists of file paths that should be | 121 The entries in this section are lists of file paths that should be considered |
118 considered equivalent when combining data from different machines:: | 122 equivalent when combining data from different machines:: |
119 | 123 |
120 [paths] | 124 [paths] |
121 source = | 125 source = |
122 src/ | 126 src/ |
123 /jenkins/build/*/src | 127 /jenkins/build/*/src |
124 c:\myproj\src | 128 c:\myproj\src |
125 | 129 |
126 The names of the entries are ignored, you may choose any name that | 130 The names of the entries are ignored, you may choose any name that you like. |
127 you like. The value is a lists of strings. When combining data | 131 The value is a lists of strings. When combining data with the ``combine`` |
128 with the ``combine`` command, two file paths will be combined | 132 command, two file paths will be combined if they start with paths from the same |
129 if they start with paths from the same list. | 133 list. |
130 | 134 |
131 The first value must be an actual file path on the machine where | 135 The first value must be an actual file path on the machine where the reporting |
132 the reporting will happen, so that source code can be found. | 136 will happen, so that source code can be found. The other values can be file |
133 The other values can be file patterns to match against the paths | 137 patterns to match against the paths of collected data, or they can be absolute |
134 of collected data. | 138 or relative file paths on the current machine. |
135 | 139 |
136 See :ref:`cmd_combining` for more information. | 140 See :ref:`cmd_combining` for more information. |
137 | 141 |
138 | 142 |
139 [report] | 143 [report] |
140 -------- | 144 -------- |
141 | 145 |
142 Values common to many kinds of reporting. | 146 Values common to many kinds of reporting. |
143 | 147 |
144 ``exclude_lines`` (multi-string): a list of regular expressions. Any line of | 148 ``exclude_lines`` (multi-string): a list of regular expressions. Any line of |
(...skipping 11 matching lines...) Expand all Loading... |
156 ``omit`` (multi-string): a list of filename patterns, the files to leave out | 160 ``omit`` (multi-string): a list of filename patterns, the files to leave out |
157 of reporting. See :ref:`source` for details. | 161 of reporting. See :ref:`source` for details. |
158 | 162 |
159 ``partial_branches`` (multi-string): a list of regular expressions. Any line | 163 ``partial_branches`` (multi-string): a list of regular expressions. Any line |
160 of code that matches one of these regexes is excused from being reported as | 164 of code that matches one of these regexes is excused from being reported as |
161 a partial branch. More details are in :ref:`branch`. If you use this option, | 165 a partial branch. More details are in :ref:`branch`. If you use this option, |
162 you are replacing all the partial branch regexes so you'll need to also | 166 you are replacing all the partial branch regexes so you'll need to also |
163 supply the "pragma: no branch" regex if you still want to use it. | 167 supply the "pragma: no branch" regex if you still want to use it. |
164 | 168 |
165 ``precision`` (integer): the number of digits after the decimal point to | 169 ``precision`` (integer): the number of digits after the decimal point to |
166 display for reported coverage percentages. The default is 0, displaying | 170 display for reported coverage percentages. The default is 0, displaying for |
167 for example "87%". A value of 2 will display percentages like "87.32%". | 171 example "87%". A value of 2 will display percentages like "87.32%". |
168 | 172 |
169 ``show_missing`` (boolean, default False): when running a summary report, | 173 ``show_missing`` (boolean, default False): when running a summary report, show |
170 show missing lines. See :ref:`cmd_summary` for more information. | 174 missing lines. See :ref:`cmd_summary` for more information. |
171 | 175 |
172 | 176 |
173 .. _config_html: | 177 .. _config_html: |
174 | 178 |
175 [html] | 179 [html] |
176 ------ | 180 ------ |
177 | 181 |
178 Values particular to HTML reporting. The values in the ``[report]`` section | 182 Values particular to HTML reporting. The values in the ``[report]`` section |
179 also apply to HTML output, where appropriate. | 183 also apply to HTML output, where appropriate. |
180 | 184 |
181 ``directory`` (string, default "htmlcov"): where to write the HTML report files. | 185 ``directory`` (string, default "htmlcov"): where to write the HTML report files. |
182 | 186 |
183 ``extra_css`` (string): the path to a file of CSS to apply to the HTML report. | 187 ``extra_css`` (string): the path to a file of CSS to apply to the HTML report. |
184 The file will be copied into the HTML output directory. Don't name it | 188 The file will be copied into the HTML output directory. Don't name it |
185 "style.css". This CSS is in addition to the CSS normally used, though you can | 189 "style.css". This CSS is in addition to the CSS normally used, though you can |
186 overwrite as many of the rules as you like. | 190 overwrite as many of the rules as you like. |
187 | 191 |
188 ``title`` (string, default "Coverage report"): the title to use for the report. | 192 ``title`` (string, default "Coverage report"): the title to use for the report. |
189 Note this is text, not HTML. | 193 Note this is text, not HTML. |
190 | 194 |
191 | 195 |
192 [xml] | 196 [xml] |
193 ----- | 197 ----- |
194 | 198 |
195 Values particular to XML reporting. The values in the ``[report]`` section | 199 Values particular to XML reporting. The values in the ``[report]`` section |
196 also apply to XML output, where appropriate. | 200 also apply to XML output, where appropriate. |
197 | 201 |
198 ``output`` (string, default "coverage.xml"): where to write the XML report. | 202 ``output`` (string, default "coverage.xml"): where to write the XML report. |
OLD | NEW |