diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-03 22:04:50 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-03 22:04:50 -0400 |
commit | 230219b50f515b93adc9fc5c3aee5cc256876b0d (patch) | |
tree | fc155f53408df68585e3b23f64c726d554c8e0c9 /coverage/data.py | |
parent | c5216efa983a4821b2680f14021d0dab6961c360 (diff) | |
download | python-coveragepy-git-230219b50f515b93adc9fc5c3aee5cc256876b0d.tar.gz |
I meant for the list of lines to be sorted.
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/coverage/data.py b/coverage/data.py index e913a9f0..a616f536 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -3,6 +3,17 @@ import os import cPickle as pickle +# Python 2.3 compatibility: it doesn't have `sorted`. +try: + sorted +except NameError: + def sorted(iterable): # pylint: disable-msg=W0622 + """A 2.3-compatible implementation of `sorted`.""" + lst = list(iterable) + lst.sort() + return lst + + class CoverageData: """Manages collected coverage data, including file storage. @@ -10,7 +21,8 @@ class CoverageData: * collector: a string identifying the collecting software - * lines: a dict mapping filenames to lists of line numbers executed: + * lines: a dict mapping filenames to sorted lists of line numbers + executed: { 'file1': [17,23,45], 'file2': [1,2,3], ... } """ @@ -90,7 +102,7 @@ class CoverageData: def line_data(self): """Return the map from filenames to lists of line numbers executed.""" return dict( - [(f, list(linemap.keys())) for f, linemap in self.lines.items()] + [(f, sorted(linemap.keys())) for f, linemap in self.lines.items()] ) def write_file(self, filename): |