diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-13 07:23:09 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-13 07:23:09 -0400 |
commit | 5049ce0519d3456e09b5ce7bac3c75c2ec9be5f1 (patch) | |
tree | ccea5c0161b1b57af2a130496a2fa43a7ca1811b /coverage/annotate.py | |
parent | e8531ee7c5766b7468b6f19ae5837c63f5f18a15 (diff) | |
download | python-coveragepy-5049ce0519d3456e09b5ce7bac3c75c2ec9be5f1.tar.gz |
Add some excluded lines to the annotation tests, and write some docstrings for annotate.py
Diffstat (limited to 'coverage/annotate.py')
-rw-r--r-- | coverage/annotate.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/coverage/annotate.py b/coverage/annotate.py index ece6333..3cbe240 100644 --- a/coverage/annotate.py +++ b/coverage/annotate.py @@ -5,6 +5,27 @@ import os, re from coverage.report import Reporter class AnnotateReporter(Reporter): + """Generate annotated source files showing line coverage. + + This reporter creates annotated copies of the measured source files. Each + .py file is copied as a .py,cover file, with a left-hand margin annotating + each line:: + + > def h(x): + - if 0: #pragma: no cover + - pass + > if x == 1: + ! a = 1 + > else: + > a = 2 + + > h(2) + + Executed lines use '>', lines not executed use '!', lines excluded from + consideration use '-'. + + """ + def __init__(self, coverage, ignore_errors=False): super(AnnotateReporter, self).__init__(coverage, ignore_errors) self.directory = None @@ -13,6 +34,7 @@ class AnnotateReporter(Reporter): else_re = re.compile(r"\s*else\s*:\s*(#|$)") def report(self, morfs, directory=None, omit_prefixes=None): + """Run the report.""" self.report_files(self.annotate_file, morfs, directory, omit_prefixes) def annotate_file(self, cu, statements, excluded, missing): |