summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <nedbat@gmail.com>2015-04-24 20:17:09 -0400
committerNed Batchelder <nedbat@gmail.com>2015-04-24 20:17:09 -0400
commitbb03090a714dc9f9c9a5b0ea3b36af05cfe7bc1a (patch)
tree407ffb056d4e08f0a8238ee766856a17af1ca83d /tests
parent5d35a6e0ce6b96b37843a0e8f0fa52f3d015cb10 (diff)
parent22612b88e8cb8c61edaed97827d7910b11130415 (diff)
downloadpython-coveragepy-git-bb03090a714dc9f9c9a5b0ea3b36af05cfe7bc1a.tar.gz
Merged in clytwynec/coverage.py/combine-from-multiple-dirs (pull request #51)
Added ability to combine coverage data files from multiple directories into one file via command line args.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmdline.py11
-rw-r--r--tests/test_data.py30
2 files changed, 39 insertions, 2 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index 775e0033..b616ed51 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -213,11 +213,18 @@ class CmdLineTest(BaseCmdLineTest):
""")
def test_combine(self):
- # coverage combine
+ # coverage combine with args
+ self.cmd_executes("combine datadir1", """\
+ .coverage()
+ .load()
+ .combine(["datadir1"])
+ .save()
+ """)
+ # coverage combine without args
self.cmd_executes("combine", """\
.coverage()
.load()
- .combine()
+ .combine(None)
.save()
""")
diff --git a/tests/test_data.py b/tests/test_data.py
index 0549a3c0..ef57f0cb 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -1,5 +1,8 @@
"""Tests for coverage.data"""
+import os
+import shutil
+
from coverage.backward import pickle
from coverage.data import CoverageData
from coverage.files import PathAliases
@@ -154,3 +157,30 @@ class DataTest(CoverageTest):
covdata3, {'./a.py': 4, './sub/b.py': 2}, fullpath=True
)
self.assert_measured_files(covdata3, ['./a.py', './sub/b.py'])
+
+
+class DataTestInTempDir(DataTest):
+ """Test cases for coverage.data."""
+
+ run_in_temp_dir = True
+
+ def test_combining_from_different_directories(self):
+ covdata1 = CoverageData()
+ covdata1.add_line_data(DATA_1)
+ os.makedirs('cov1')
+ covdata1.write_file('cov1/.coverage.1')
+
+ covdata2 = CoverageData()
+ covdata2.add_line_data(DATA_2)
+ os.makedirs('cov2')
+ covdata2.write_file('cov2/.coverage.2')
+
+ covdata3 = CoverageData()
+ covdata3.combine_parallel_data(data_dirs=[
+ 'cov1/',
+ 'cov2/',
+ ])
+
+ self.assert_summary(covdata3, SUMMARY_1_2)
+ self.assert_measured_files(covdata3, MEASURED_FILES_1_2)
+