diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-31 06:33:24 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-31 06:33:24 -0500 |
commit | 45700567d180d871a5fc7c9435ec5058e28e23cf (patch) | |
tree | 8a8b5b01693520029c05c8f5afe30d0f78d3316f /tests/test_concurrency.py | |
parent | 3be0790dd8e844ddb597fd09e3d768cbca85ae43 (diff) | |
download | python-coveragepy-45700567d180d871a5fc7c9435ec5058e28e23cf.tar.gz |
Multiprocess support doesn't work yet on Windows.
Diffstat (limited to 'tests/test_concurrency.py')
-rw-r--r-- | tests/test_concurrency.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index 928f940..b745f86 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): |