diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-09-27 10:01:05 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-09-27 10:01:05 -0400 |
commit | c4c25e13b8468655ff69c9783df4534c217730be (patch) | |
tree | 4b8e90115c2145cd3911f9a7983f7cc0fa140ddd /coverage/data.py | |
parent | bc89904a4566cec370e7ad5166b0ab791b911035 (diff) | |
download | python-coveragepy-c4c25e13b8468655ff69c9783df4534c217730be.tar.gz |
Added a 'coverage debug' command to get internal information for diagnosing problems. Also, all commands should at least take -h.
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/coverage/data.py b/coverage/data.py index 4d368f5..5497965 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -164,14 +164,19 @@ class CoverageData: """ return self.lines.get(filename) or {} - def summary(self): + def summary(self, fullpath=False): """Return a dict summarizing the coverage data. - Keys are the basename of the filenames, and values are the number of - executed lines. This is useful in the unit tests. + Keys are based on the filenames, and values are the number of executed + lines. If `fullpath` is true, then the keys are the full pathnames of + the files, otherwise they are the basenames of the files. """ summ = {} + if fullpath: + filename_fn = lambda f: f + else: + filename_fn = os.path.basename for filename, lines in self.lines.items(): - summ[os.path.basename(filename)] = len(lines) + summ[filename_fn(filename)] = len(lines) return summ |