summaryrefslogtreecommitdiff
path: root/tests/test_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
commitb76e5fd7146b48947c0a9a41fc47899a0227c339 (patch)
treefbf6cc4b1abf45b1ac9a4651d34ab00e54e5fa3d /tests/test_data.py
parentb88c58b927eddb401f7e901025155b3302c3ae61 (diff)
downloadpython-coveragepy-git-b76e5fd7146b48947c0a9a41fc47899a0227c339.tar.gz
Fix and test add_to_hash: test_data.py now 100% covers data.py
Diffstat (limited to 'tests/test_data.py')
-rw-r--r--tests/test_data.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index d43e0308..c654c8fc 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -4,6 +4,8 @@ import glob
import os
import os.path
+import mock
+
from coverage.backward import pickle
from coverage.data import CoverageData, CoverageDataFiles
from coverage.files import PathAliases, canonical_filename
@@ -263,6 +265,27 @@ class CoverageDataTest(DataTestHelpers, CoverageTest):
with self.assertRaises(CoverageException):
covdata2.update(covdata1)
+ def test_add_to_hash_with_lines(self):
+ covdata = CoverageData()
+ covdata.add_lines(LINES_1)
+ hasher = mock.Mock()
+ covdata.add_to_hash("a.py", hasher)
+ self.assertEqual(hasher.method_calls, [
+ mock.call.update([1, 2]), # lines
+ mock.call.update(""), # plugin name
+ ])
+
+ def test_add_to_hash_with_arcs(self):
+ covdata = CoverageData()
+ covdata.add_arcs(ARCS_3)
+ covdata.add_plugins({"y.py": "hologram_plugin"})
+ hasher = mock.Mock()
+ covdata.add_to_hash("y.py", hasher)
+ self.assertEqual(hasher.method_calls, [
+ mock.call.update([(-1, 17), (17, 23), (23, -1)]), # arcs
+ mock.call.update("hologram_plugin"), # plugin name
+ ])
+
class CoverageDataTestInTempDir(DataTestHelpers, CoverageTest):
"""Tests of CoverageData that need a temp dir to make files."""