| OLD | NEW |
| (Empty) |
| 1 .. _source: | |
| 2 | |
| 3 ======================= | |
| 4 Specifying source files | |
| 5 ======================= | |
| 6 | |
| 7 :history: 20100725T172000, new in 3.4 | |
| 8 | |
| 9 | |
| 10 When coverage.py is running your program and measuring its execution, it needs | |
| 11 to know what code to measure and what code not to. Measurement imposes a speed | |
| 12 penalty, and the collected data must be stored in memory and then on disk. | |
| 13 More importantly, when reviewing your coverage reports, you don't want to be | |
| 14 distracted with modules that aren't your concern. | |
| 15 | |
| 16 Coverage.py has a number of ways you can focus it in on the code you care | |
| 17 about. | |
| 18 | |
| 19 | |
| 20 .. _source_execution: | |
| 21 | |
| 22 Execution | |
| 23 --------- | |
| 24 | |
| 25 When running your code, the ``coverage run`` command will by default measure | |
| 26 all code, unless it is part of the Python standard library. | |
| 27 | |
| 28 You can specify source to measure with the ``--source`` command-line switch, | |
| 29 or the ``[run] source`` configuration value. The value is a list of directories | |
| 30 or package names. If specified, only source inside these directories or | |
| 31 packages will be measured. Specifying the source option also enables | |
| 32 coverage.py to report on unexecuted files, since it can search the source tree | |
| 33 for files that haven't been measured at all. | |
| 34 | |
| 35 You can further fine-tune coverage.py's attention with the ``--include`` and | |
| 36 ``--omit`` switches (or ``[run] include`` and ``[run] omit`` configuration | |
| 37 values). ``--include`` is a list of filename patterns. If specified, only files | |
| 38 matching those patterns will be measured. ``--omit`` is also a list of filename | |
| 39 patterns, specifying files not to measure. If both ``include`` and ``omit`` | |
| 40 are specified, first the set of files is reduced to only those that match the | |
| 41 include patterns, then any files that match the omit pattern are removed from | |
| 42 the set. | |
| 43 | |
| 44 The ``include`` and ``omit`` filename patterns follow typical shell syntax: | |
| 45 ``*`` matches any number of characters and ``?`` matches a single character. | |
| 46 Patterns that start with a wildcard character are used as-is, other patterns | |
| 47 are interpreted relative to the current directory. | |
| 48 | |
| 49 The ``source``, ``include``, and ``omit`` values all work together to determine | |
| 50 the source that will be measured. | |
| 51 | |
| 52 | |
| 53 .. _source_reporting: | |
| 54 | |
| 55 Reporting | |
| 56 --------- | |
| 57 | |
| 58 Once your program is measured, you can specify the source files you want | |
| 59 reported. Usually you want to see all the code that was measured, but if you | |
| 60 are measuring a large project, you may want to get reports for just certain | |
| 61 parts. | |
| 62 | |
| 63 The report commands (``report``, ``html``, ``annotate``, and ``xml``) all take | |
| 64 optional ``modules`` arguments, and ``--include`` and ``--omit`` switches. The | |
| 65 ``modules`` arguments specify particular modules to report on. The ``include`` | |
| 66 and ``omit`` values are lists of filename patterns, just as with the ``run`` | |
| 67 command. | |
| 68 | |
| 69 Remember that the reporting commands can only report on the data that has been | |
| 70 collected, so the data you're looking for may not be in the data available for | |
| 71 reporting. | |
| 72 | |
| 73 Note that these are ways of specifying files to measure. You can also exclude | |
| 74 individual source lines. See :ref:`excluding` for details. | |
| OLD | NEW |