summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-20 07:00:04 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-20 07:00:04 -0400
commit3c6c983fe91068d056b8bc97b15f4ae23903e2af (patch)
treeae47935db8b9e7b35fafb110939ca78928a0a440 /coverage/data.py
parentad16958655032e4d4f31ab87fd27d29b84c84ad9 (diff)
downloadpython-coveragepy-3c6c983fe91068d056b8bc97b15f4ae23903e2af.tar.gz
Fix and test add_to_hash: test_data.py now 100% covers data.py
Diffstat (limited to 'coverage/data.py')
-rw-r--r--coverage/data.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/coverage/data.py b/coverage/data.py
index f2e528d..e5c37cb 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -267,9 +267,19 @@ class CoverageData(object):
return list(self._arcs or self._lines)
def add_to_hash(self, filename, hasher):
- """Contribute `filename`'s data to the Md5Hash `hasher`."""
- hasher.update(self.lines(filename))
- hasher.update(self.arcs(filename))
+ """Contribute `filename`'s data to the `hasher`.
+
+ Arguments:
+ filename (str): the filename we're interested in.
+ hasher (:class:`coverage.misc.Hasher`): the Hasher to update with
+ the file's data.
+
+ """
+ if self._arcs:
+ hasher.update(sorted(self.arcs(filename)))
+ else:
+ hasher.update(sorted(self.lines(filename)))
+ hasher.update(self.plugin_name(filename))
def line_counts(self, fullpath=False):
"""Return a dict summarizing the line coverage data.