summaryrefslogtreecommitdiff
path: root/tests/test_concurrency.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-08-05 12:03:45 -0700
committerGitHub <noreply@github.com>2021-08-05 12:03:45 -0700
commit1f51202aec24679be776ea759efb66070100c3c3 (patch)
tree4c3a69e9462dce1b8fe763caab663ab2f5ea09f5 /tests/test_concurrency.py
parent4ef91bd9fc954c7182480440e5ce9346073b9270 (diff)
downloadpython-coveragepy-git-1f51202aec24679be776ea759efb66070100c3c3.tar.gz
feat: `coverage combine` now prints messages naming the files being combined. #1105 (#1208)
Diffstat (limited to 'tests/test_concurrency.py')
-rw-r--r--tests/test_concurrency.py30
1 files changed, 18 insertions, 12 deletions
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", """\