diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-12 07:06:15 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-12 07:06:15 -0400 |
commit | 8cd21bb4c90f5bd8c552df1eba895bdb99bc6dc6 (patch) | |
tree | 71813d14d9ac5f32ea770f8cb0a5e380492b1792 /coverage/data.py | |
parent | f03b0bf7492702ade97be7dca2b2d88c06433b85 (diff) | |
download | python-coveragepy-git-8cd21bb4c90f5bd8c552df1eba895bdb99bc6dc6.tar.gz |
Write the arcs to the data file.
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/coverage/data.py b/coverage/data.py index b61adcd6..1744a7fb 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -16,7 +16,8 @@ class CoverageData: executed: { 'file1': [17,23,45], 'file2': [1,2,3], ... } - * arcs: TODO + * arcs: a dict mapping filenames to sorted lists of line number pairs: + { 'file1': [(17,23), (17,25), (25,26)], ... } """ @@ -93,6 +94,12 @@ class CoverageData: [(f, sorted(lmap.keys())) for f, lmap in self.lines.items()] ) + def arc_data(self): + """Return the map from filenames to lists of line number pairs.""" + return dict( + [(f, sorted(amap.keys())) for f, amap in self.arcs.items()] + ) + def write_file(self, filename): """Write the coverage data to `filename`.""" @@ -100,7 +107,8 @@ class CoverageData: data = {} data['lines'] = self.line_data() - + data['arcs'] = self.arc_data() + if self.collector: data['collector'] = self.collector @@ -129,7 +137,12 @@ class CoverageData: # Unpack the 'lines' item. lines = dict([ (f, dict.fromkeys(linenos, None)) - for f, linenos in data['lines'].items() + for f, linenos in data.get('lines', {}).items() + ]) + # Unpack the 'arcs' item. + arcs = dict([ + (f, dict.fromkeys(arcpairs, None)) + for f, arcpairs in data.get('arcs', {}).items() ]) except Exception: pass |