summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_api.py4
-rw-r--r--tests/test_concurrency.py30
2 files changed, 22 insertions, 12 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 885f3370..5f7b3522 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -437,6 +437,7 @@ class ApiTest(CoverageTest):
self.make_good_data_files()
cov1 = coverage.Coverage()
cov1.combine()
+ assert self.stdout() == ""
cov1.save()
self.check_code1_code2(cov1)
self.assert_file_count(".coverage.*", 0)
@@ -448,6 +449,7 @@ class ApiTest(CoverageTest):
cov3 = coverage.Coverage()
cov3.combine()
+ assert self.stdout() == ""
# Now the data is empty!
_, statements, missing, _ = cov3.analysis("code1.py")
assert statements == [1]
@@ -469,6 +471,7 @@ class ApiTest(CoverageTest):
cov.save()
cov.combine()
+ assert self.stdout() == ""
self.check_code1_code2(cov)
def test_ordered_combine(self):
@@ -483,6 +486,7 @@ class ApiTest(CoverageTest):
def get_combined_filenames():
cov = coverage.Coverage()
cov.combine()
+ assert self.stdout() == ""
cov.save()
data = cov.get_data()
filenames = {relative_filename(f).replace("\\", "/") for f in data.measured_files()}
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index e1606e83..682e3cf0 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -392,7 +392,12 @@ class MultiprocessingTest(CoverageTest):
assert len(glob.glob(".coverage.*")) == nprocs + 1
out = self.run_command("coverage combine")
- assert out == ""
+ out_lines = out.splitlines()
+ assert len(out_lines) == nprocs + 1
+ assert all(
+ re.fullmatch(r"Combined data file \.coverage\..*\.\d+\.\d+", line)
+ for line in out_lines
+ )
out = self.run_command("coverage report -m")
last_line = self.squeezed_lines(out)[-1]
@@ -426,8 +431,12 @@ class MultiprocessingTest(CoverageTest):
code, expected_out, eventlet, nprocs, concurrency="multiprocessing,eventlet"
)
- def try_multiprocessing_code_with_branching(self, code, expected_out):
- """Run code using multiprocessing, it should produce `expected_out`."""
+ def test_multiprocessing_with_branching(self):
+ nprocs = 3
+ upto = 30
+ code = (SQUARE_OR_CUBE_WORK + MULTI_CODE).format(NPROCS=nprocs, UPTO=upto)
+ total = sum(x*x if x%2 else x*x*x for x in range(upto))
+ expected_out = f"{nprocs} pids, total = {total}"
self.make_file("multi.py", code)
self.make_file("multi.rc", """\
[run]
@@ -444,20 +453,17 @@ class MultiprocessingTest(CoverageTest):
assert out.rstrip() == expected_out
out = self.run_command("coverage combine")
- assert out == ""
+ out_lines = out.splitlines()
+ assert len(out_lines) == nprocs + 1
+ assert all(
+ re.fullmatch(r"Combined data file \.coverage\..*\.\d+\.\d+", line)
+ for line in out_lines
+ )
out = self.run_command("coverage report -m")
last_line = self.squeezed_lines(out)[-1]
assert re.search(r"TOTAL \d+ 0 \d+ 0 100%", last_line)
- def test_multiprocessing_with_branching(self):
- nprocs = 3
- upto = 30
- code = (SQUARE_OR_CUBE_WORK + MULTI_CODE).format(NPROCS=nprocs, UPTO=upto)
- total = sum(x*x if x%2 else x*x*x for x in range(upto))
- expected_out = f"{nprocs} pids, total = {total}"
- self.try_multiprocessing_code_with_branching(code, expected_out)
-
def test_multiprocessing_bootstrap_error_handling(self):
# An exception during bootstrapping will be reported.
self.make_file("multi.py", """\