summaryrefslogtreecommitdiff
path: root/tests/test_concurrency.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_concurrency.py')
-rw-r--r--tests/test_concurrency.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index e36db30d..841b5df4 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -3,9 +3,10 @@
"""Tests for concurrency libraries."""
-import multiprocessing
import threading
+from flaky import flaky
+
import coverage
from coverage import env
from coverage.files import abs_file
@@ -16,6 +17,11 @@ from tests.coveragetest import CoverageTest
# These libraries aren't always available, we'll skip tests if they aren't.
try:
+ import multiprocessing
+except ImportError: # pragma: only jython
+ multiprocessing = None
+
+try:
import eventlet
except ImportError:
eventlet = None
@@ -25,7 +31,10 @@ try:
except ImportError:
gevent = None
-import greenlet
+try:
+ import greenlet
+except ImportError: # pragma: only jython
+ greenlet = None
def measurable_line(l):
@@ -40,6 +49,9 @@ def measurable_line(l):
return False
if l.startswith('else:'):
return False
+ if env.JYTHON and l.startswith(('try:', 'except:', 'except ', 'break', 'with ')):
+ # Jython doesn't measure these statements.
+ return False # pragma: only jython
return True
@@ -342,9 +354,15 @@ MULTI_CODE = """
"""
+@flaky # Sometimes a test fails due to inherent randomness. Try one more time.
class MultiprocessingTest(CoverageTest):
"""Test support of the multiprocessing module."""
+ def setUp(self):
+ super(MultiprocessingTest, self).setUp()
+ if not multiprocessing:
+ self.skipTest("No multiprocessing in this Python") # pragma: only jython
+
def try_multiprocessing_code(
self, code, expected_out, the_module, concurrency="multiprocessing"
):
@@ -353,6 +371,7 @@ class MultiprocessingTest(CoverageTest):
self.make_file(".coveragerc", """\
[run]
concurrency = %s
+ source = .
""" % concurrency)
if env.PYVERSION >= (3, 4):