diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-20 07:00:04 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-20 07:00:04 -0400 |
commit | 3c6c983fe91068d056b8bc97b15f4ae23903e2af (patch) | |
tree | ae47935db8b9e7b35fafb110939ca78928a0a440 /tests | |
parent | ad16958655032e4d4f31ab87fd27d29b84c84ad9 (diff) | |
download | python-coveragepy-3c6c983fe91068d056b8bc97b15f4ae23903e2af.tar.gz |
Fix and test add_to_hash: test_data.py now 100% covers data.py
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_data.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_data.py b/tests/test_data.py index d43e030..c654c8f 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.""" |