summaryrefslogtreecommitdiff
path: root/tests/test_data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-23 07:36:28 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-23 07:36:28 -0400
commit18dbb90b252c2b7b4386fd0b6ebf001d3a248ef8 (patch)
treed5c28a3f77053583c6464d643202ac89126ee8f9 /tests/test_data.py
parent2cc4228e4b7543418d7e14d9eca66f7263870cf3 (diff)
downloadpython-coveragepy-git-18dbb90b252c2b7b4386fd0b6ebf001d3a248ef8.tar.gz
Test (and fix!) the secret data dumper.
Diffstat (limited to 'tests/test_data.py')
-rw-r--r--tests/test_data.py56
1 files changed, 54 insertions, 2 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index ef058e51..708177f9 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -4,10 +4,11 @@ import glob
import json
import os
import os.path
+import textwrap
import mock
-from coverage.data import CoverageData, CoverageDataFiles
+from coverage.data import CoverageData, CoverageDataFiles, debug_main
from coverage.files import PathAliases, canonical_filename
from coverage.misc import CoverageException
@@ -358,9 +359,60 @@ class CoverageDataTestInTempDir(DataTestHelpers, CoverageTest):
with self.assertRaisesRegex(CoverageException, msg.format("nonexistent.dat")):
covdata.read_file("nonexistent.dat")
- # and after all that, no data should be in our CoverageData.
+ # After all that, no data should be in our CoverageData.
self.assertFalse(covdata)
+ def test_debug_main(self):
+ covdata1 = CoverageData()
+ covdata1.set_lines(LINES_1)
+ covdata1.write_file(".coverage")
+ debug_main([])
+
+ covdata2 = CoverageData()
+ covdata2.set_arcs(ARCS_3)
+ covdata2.set_plugins({"y.py": "magic_plugin"})
+ covdata2.write_file("arcs.dat")
+
+ covdata3 = CoverageData()
+ covdata3.write_file("empty.dat")
+ debug_main(["arcs.dat", "empty.dat"])
+
+ self.assertEqual(self.stdout(), textwrap.dedent("""\
+ --- .coverage ------------------------------
+ {
+ "lines": {
+ "a.py": [1, 2],
+ "b.py": [
+ 3
+ ]
+ }
+ }
+ --- arcs.dat ------------------------------
+ {
+ "arcs": {
+ "x.py": [
+ [1, 2],
+ [-1, 1],
+ [2, 3],
+ [3, -1]
+ ],
+ "y.py": [
+ [-1, 17],
+ [23, -1],
+ [17, 23]
+ ]
+ },
+ "plugins": {
+ "y.py": "magic_plugin"
+ }
+ }
+ --- empty.dat ------------------------------
+ {
+ "lines": {}
+ }
+ """)
+ )
+
class CoverageDataFilesTest(DataTestHelpers, CoverageTest):
"""Tests of CoverageDataFiles."""