summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-01-31 06:33:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-01-31 06:33:24 -0500
commit23c62e9b1d139b9d468b1ad3612727fb0898a6f3 (patch)
tree4b1b51decbf4d686196761b9dd19317ee0231b1c
parent6c631d76f22c50220bba51ec3191260d7e74b11f (diff)
downloadpython-coveragepy-git-23c62e9b1d139b9d468b1ad3612727fb0898a6f3.tar.gz
Multiprocess support doesn't work yet on Windows.
-rw-r--r--CHANGES.txt4
-rw-r--r--tests/test_concurrency.py19
2 files changed, 17 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 013820c5..c0166bb8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,8 +8,8 @@ Latest
- Wildly experimental: support for measuring processes started by the
multiprocessing module. To use, set ``--concurrency=multiprocessing``,
- either on the command line or in the .coveragerc file. Thanks, Eduardo
- Schettino. (`issue 117`_).
+ either on the command line or in the .coveragerc file (`issue 117`_). Thanks,
+ Eduardo Schettino. Currently, this does not work on Windows.
- A new warning is possible, if a desired file isn't measured because it was
imported before coverage was started (`issue 353`_).
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index 928f9404..b745f86f 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -4,6 +4,8 @@ import os
import os.path
import threading
+from nose.plugins.skip import SkipTest
+
import coverage
from coverage import env
@@ -223,6 +225,13 @@ class ConcurrencyTest(CoverageTest):
class MultiprocessingTest(CoverageTest):
"""Test support of the multiprocessing module."""
+ def setUp(self):
+ # Currently, this doesn't work on Windows, something about pickling
+ # the monkey-patched Process class?
+ if env.WINDOWS:
+ raise SkipTest
+ super(MultiprocessingTest, self).setUp()
+
def test_multiprocessing(self):
self.make_file("multi.py", """\
import multiprocessing
@@ -233,10 +242,12 @@ class MultiprocessingTest(CoverageTest):
# Need to pause, or the tasks go too quick, and some processes
# in the pool don't get any work, and then don't record data.
time.sleep(0.01)
+ # Use different lines in different subprocesses.
if x % 2:
- return os.getpid(), x*x
+ y = x*x
else:
- return os.getpid(), x*x
+ y = x*x*x
+ return os.getpid(), y
if __name__ == "__main__":
pool = multiprocessing.Pool(3)
@@ -256,13 +267,13 @@ class MultiprocessingTest(CoverageTest):
"coverage run --concurrency=multiprocessing multi.py"
)
os.system("cp .cov* /tmp")
- total = sum(x*x for x in range(20))
+ total = sum(x*x if x%2 else x*x*x for x in range(20))
self.assertEqual(out.rstrip(), "3 pids, total = %d" % total)
self.run_command("coverage combine")
out = self.run_command("coverage report -m")
last_line = self.squeezed_lines(out)[-1]
- self.assertEqual(last_line, "multi.py 20 0 100%")
+ self.assertEqual(last_line, "multi.py 21 0 100%")
def print_simple_annotation(code, linenos):