summaryrefslogtreecommitdiff
path: root/tests/test_data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-18 15:19:16 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-18 15:19:16 -0400
commitb974729cedc7c967be07314fc4a20815575cc618 (patch)
treea3b9385d6973f217abc022ffdcbe134c4f41b3bc /tests/test_data.py
parent2283cfd510d36068845ad085d78b77e4c01a228a (diff)
downloadpython-coveragepy-git-b974729cedc7c967be07314fc4a20815575cc618.tar.gz
Add test of the debug output when reading/writing data
Diffstat (limited to 'tests/test_data.py')
-rw-r--r--tests/test_data.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index 4acfd63e..9d909705 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -7,7 +7,7 @@ from coverage.backward import pickle
from coverage.data import CoverageData, CoverageDataFiles
from coverage.files import PathAliases, canonical_filename
-from tests.coveragetest import CoverageTest
+from tests.coveragetest import CoverageTest, DebugControlString
DATA_1 = {
@@ -128,6 +128,38 @@ class DataFilesTest(DataTestHelpers, CoverageTest):
self.data_files.read(covdata2)
self.assert_line_counts(covdata2, SUMMARY_1)
+ def test_debug_output_with_debug_option(self):
+ # With debug option dataio, we get debug output about reading and
+ # writing files.
+ debug = DebugControlString(options=["dataio"])
+ covdata1 = CoverageData(debug=debug)
+ covdata1.add_lines(DATA_1)
+ self.data_files.write(covdata1)
+
+ covdata2 = CoverageData(debug=debug)
+ self.data_files.read(covdata2)
+ self.assert_line_counts(covdata2, SUMMARY_1)
+
+ self.assertRegex(
+ debug.get_output(),
+ r"^Writing data to '.*\.coverage'\n"
+ r"Reading data from '.*\.coverage'\n$"
+ )
+
+ def test_debug_output_without_debug_option(self):
+ # With a debug object, but not the dataio option, we don't get debug
+ # output.
+ debug = DebugControlString(options=[])
+ covdata1 = CoverageData(debug=debug)
+ covdata1.add_lines(DATA_1)
+ self.data_files.write(covdata1)
+
+ covdata2 = CoverageData(debug=debug)
+ self.data_files.read(covdata2)
+ self.assert_line_counts(covdata2, SUMMARY_1)
+
+ self.assertEqual(debug.get_output(), "")
+
def test_combining(self):
covdata1 = CoverageData()
covdata1.add_lines(DATA_1)