summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/coveragetest.py3
-rw-r--r--tests/test_api.py2
-rw-r--r--tests/test_concurrency.py16
3 files changed, 17 insertions, 4 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 539dd594..7ec623b3 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -6,6 +6,7 @@
import contextlib
import datetime
import glob
+import itertools
import os
import random
import re
@@ -73,7 +74,7 @@ class CoverageTest(
# Also have to clean out the .pyc file, since the timestamp
# resolution is only one second, a changed file might not be
# picked up.
- for pyc in glob.glob('*.pyc'):
+ for pyc in itertools.chain(glob.glob('*.pyc'), glob.glob('*$py.class')):
os.remove(pyc)
if os.path.exists("__pycache__"):
shutil.rmtree("__pycache__")
diff --git a/tests/test_api.py b/tests/test_api.py
index 6f142100..9de83fb2 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -35,7 +35,7 @@ class ApiTest(CoverageTest):
def assertFiles(self, files):
"""Assert that the files here are `files`, ignoring the usual junk."""
here = os.listdir(".")
- here = self.clean_files(here, ["*.pyc", "__pycache__"])
+ here = self.clean_files(here, ["*.pyc", "__pycache__", "*$py.class"])
self.assertCountEqual(here, files)
def test_unexecuted_file(self):
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index e36db30d..b441909f 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -3,7 +3,6 @@
"""Tests for concurrency libraries."""
-import multiprocessing
import threading
import coverage
@@ -16,6 +15,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 +29,10 @@ try:
except ImportError:
gevent = None
-import greenlet
+try:
+ import greenlet
+except ImportError: # pragma: only jython
+ greenlet = None
def measurable_line(l):
@@ -345,6 +352,11 @@ MULTI_CODE = """
class MultiprocessingTest(CoverageTest):
"""Test support of the multiprocessing module."""
+ def setUp(self):
+ if not multiprocessing:
+ self.skip("No multiprocessing in this Python") # pragma: only jython
+ super(MultiprocessingTest, self).setUp()
+
def try_multiprocessing_code(
self, code, expected_out, the_module, concurrency="multiprocessing"
):