summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-01-21 18:04:22 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-01-21 18:04:22 -0500
commitd9462bb69b9b96ff41a316322b9e3826061bc9ab (patch)
tree002cd985c6cc373363f272827c02c2d9c8083aa0 /tests/test_process.py
parente756776c0a9f3c78389bcc93e067ac3ac0f45ad9 (diff)
downloadpython-coveragepy-git-d9462bb69b9b96ff41a316322b9e3826061bc9ab.tar.gz
Raise an error if combine can't find usable data files. #629
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index 42a6d983..18564cb8 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -144,6 +144,40 @@ class ProcessTest(CoverageTest):
data.read_file(".coverage")
self.assertEqual(data.line_counts()['b_or_c.py'], 7)
+ def test_combine_no_usable_files(self):
+ # https://bitbucket.org/ned/coveragepy/issues/629/multiple-use-of-combine-leads-to-empty
+ self.make_b_or_c_py()
+ out = self.run_command("coverage run b_or_c.py b")
+ self.assertEqual(out, 'done\n')
+ self.assert_exists(".coverage")
+ self.assertEqual(self.number_of_data_files(), 1)
+
+ # Make bogus data files.
+ self.make_file(".coverage.bad1", "This isn't a coverage data file.")
+ self.make_file(".coverage.bad2", "This isn't a coverage data file.")
+
+ # Combine the parallel coverage data files into .coverage, but nothing is readable.
+ status, out = self.run_command_status("coverage combine")
+ self.assertEqual(status, 1)
+
+ for n in "12":
+ self.assert_exists(".coverage.bad{0}".format(n))
+ warning_regex = (
+ r"Coverage.py warning: Couldn't read data from '.*\.coverage\.bad{0}': "
+ r"CoverageException: Doesn't seem to be a coverage\.py data file".format(n)
+ )
+ self.assertRegex(out, warning_regex)
+ self.assertRegex(out, r"No usable data files")
+
+ # After combining, we should have a main file and two parallel files.
+ self.assertEqual(self.number_of_data_files(), 3)
+
+ # Read the coverage file and see that b_or_c.py has 6 lines
+ # executed (we only did b, not c).
+ data = coverage.CoverageData()
+ data.read_file(".coverage")
+ self.assertEqual(data.line_counts()['b_or_c.py'], 6)
+
def test_combine_parallel_data_in_two_steps(self):
self.make_b_or_c_py()