When running your code, the coverage run command will by default
measure all code, unless it is part of the Python standard library.
You can specify source to measure with the --source command-line
switch, or the [run] source configuration value. The value is a list
of directories or package names. If specified, only source inside
these directories or packages will be measured. Specifying the source
option also enables coverage.py to report on unexecuted files, since
it can search the source tree for files that haven’t been measured at
all. Only importable files (ones at the root of the tree, or in
directories with a __init__.py file) will be considered, and files
with unusual punctuation in their names will be skipped (they are
assumed to be scratch files written by text editors).
You can further fine-tune coverage.py’s attention with the --include
and --omit switches (or [run] include and [run] omit configuration
values). --include is a list of file name patterns. If specified, only
files matching those patterns will be measured. --omit is also a list
of file name patterns, specifying files not to measure. If both
include and omit are specified, first the set of files is reduced to
only those that match the include patterns, then any files that match
the omit pattern are removed from the set.
The include and omit file name patterns follow typical shell syntax: *
matches any number of characters and ? matches a single character.
Patterns that start with a wildcard character are used as-is, other
patterns are interpreted relative to the current directory.
The source, include, and omit values all work together to determine
the source that will be measured.
是的,他们在the docs中对此有相当广泛的支持。
相关问题 更多 >
编程相关推荐