It turns out that if my --eventlet-hub=foo command fails to import foo, I don't really want it to just write a warning, I want it to crash hard. Skipped the threading-related tests when using the libevent hub, as well as the multiple readers test, because it fails all of them.
This commit is contained in:
@@ -67,6 +67,14 @@ def requires_twisted(func):
|
||||
return skip_unless_requirement(requirement)(func)
|
||||
|
||||
|
||||
def skip_with_libevent(func):
|
||||
""" Decorator that skips a test if we're using the libevent hub."""
|
||||
def requirement(_f):
|
||||
from eventlet.api import get_hub
|
||||
return not('libevent' in type(get_hub()).__module__)
|
||||
return skip_unless_requirement(requirement)(func)
|
||||
|
||||
|
||||
class TestIsTakingTooLong(Exception):
|
||||
""" Custom exception class to be raised when a test's runtime exceeds a limit. """
|
||||
pass
|
||||
|
@@ -28,15 +28,11 @@ class EventletHub(Plugin):
|
||||
" specified, the default hub for the current configuration is printed "\
|
||||
" and used."
|
||||
|
||||
|
||||
def beforeContext(self):
|
||||
"""Select the desired hub.
|
||||
"""
|
||||
if self.hub_name is None:
|
||||
log.warn('using *default* eventlet hub: %s', api.get_hub())
|
||||
else:
|
||||
try:
|
||||
api.use_hub(self.hub_name)
|
||||
log.info('using hub %s', api.get_hub())
|
||||
except ImportError, ex:
|
||||
log.exception('eventlet hub %s not importing', self.hub_name)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
from tests import skipped, LimitedTestCase
|
||||
from tests import skipped, LimitedTestCase, skip_with_libevent
|
||||
from unittest import main
|
||||
from eventlet import api, util, coros, proc
|
||||
import os
|
||||
@@ -182,6 +182,7 @@ class TestGreenIo(LimitedTestCase):
|
||||
for bytes in (1000, 10000, 100000, 1000000):
|
||||
test_sendall_impl(bytes)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_multiple_readers(self):
|
||||
# test that we can have multiple coroutines reading
|
||||
# from the same fd. We make no guarantees about which one gets which
|
||||
|
@@ -16,7 +16,7 @@
|
||||
import random
|
||||
from sys import stdout
|
||||
import time
|
||||
from tests import skipped
|
||||
from tests import skipped, skip_with_libevent
|
||||
from unittest import TestCase, main
|
||||
import uuid
|
||||
|
||||
@@ -70,6 +70,7 @@ class TestTpool(TestCase):
|
||||
tpool.QUIET = False
|
||||
tpool.killall()
|
||||
|
||||
@skip_with_libevent
|
||||
def test_a_buncha_stuff(self):
|
||||
pool = coros.CoroutinePool(max_size=10)
|
||||
waiters = []
|
||||
@@ -78,6 +79,7 @@ class TestTpool(TestCase):
|
||||
for waiter in waiters:
|
||||
waiter.wait()
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_tuple(self):
|
||||
my_tuple = (1, 2)
|
||||
prox = tpool.Proxy(my_tuple)
|
||||
@@ -85,6 +87,7 @@ class TestTpool(TestCase):
|
||||
self.assertEqual(prox[1], 2)
|
||||
self.assertEqual(len(my_tuple), 2)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_string(self):
|
||||
my_object = "whatever"
|
||||
prox = tpool.Proxy(my_object)
|
||||
@@ -92,6 +95,7 @@ class TestTpool(TestCase):
|
||||
self.assertEqual(len(my_object), len(prox))
|
||||
self.assertEqual(my_object.join(['a', 'b']), prox.join(['a', 'b']))
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_uniterable(self):
|
||||
# here we're treating the exception as just a normal class
|
||||
prox = tpool.Proxy(FloatingPointError())
|
||||
@@ -103,6 +107,7 @@ class TestTpool(TestCase):
|
||||
self.assertRaises(IndexError, index)
|
||||
self.assertRaises(TypeError, key)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_dict(self):
|
||||
my_object = {'a':1}
|
||||
prox = tpool.Proxy(my_object)
|
||||
@@ -112,6 +117,7 @@ class TestTpool(TestCase):
|
||||
self.assertEqual(repr(my_object), repr(prox))
|
||||
self.assertEqual(`my_object`, `prox`)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_module_class(self):
|
||||
prox = tpool.Proxy(uuid)
|
||||
self.assertEqual(tpool.Proxy, type(prox))
|
||||
@@ -119,6 +125,7 @@ class TestTpool(TestCase):
|
||||
self.assertEqual(id.get_version(), uuid.uuid4().get_version())
|
||||
self.assert_(repr(prox.uuid4))
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_eq(self):
|
||||
prox = tpool.Proxy(uuid)
|
||||
id1 = prox.uuid4()
|
||||
@@ -127,6 +134,7 @@ class TestTpool(TestCase):
|
||||
id3 = prox.uuid4()
|
||||
self.assert_(id1 != id3)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_nonzero(self):
|
||||
prox = tpool.Proxy(uuid)
|
||||
id1 = prox.uuid4()
|
||||
@@ -134,6 +142,7 @@ class TestTpool(TestCase):
|
||||
prox2 = tpool.Proxy([1, 2, 3])
|
||||
self.assert_(bool(prox2))
|
||||
|
||||
@skip_with_libevent
|
||||
def test_multiple_wraps(self):
|
||||
prox1 = tpool.Proxy(uuid)
|
||||
prox2 = tpool.Proxy(uuid)
|
||||
@@ -142,15 +151,18 @@ class TestTpool(TestCase):
|
||||
del x2
|
||||
x3 = prox2.uuid4()
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_getitem(self):
|
||||
prox = tpool.Proxy([0,1,2])
|
||||
self.assertEqual(prox[0], 0)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_wrap_setitem(self):
|
||||
prox = tpool.Proxy([0,1,2])
|
||||
prox[1] = 2
|
||||
self.assertEqual(prox[1], 2)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_raising_exceptions(self):
|
||||
prox = tpool.Proxy(uuid)
|
||||
def nofunc():
|
||||
@@ -160,6 +172,7 @@ class TestTpool(TestCase):
|
||||
def assertLessThan(self, a, b):
|
||||
self.assert_(a < b, "%s is not less than %s" % (a, b))
|
||||
|
||||
@skip_with_libevent
|
||||
def test_variable_and_keyword_arguments_with_function_calls(self):
|
||||
import optparse
|
||||
parser = tpool.Proxy(optparse.OptionParser())
|
||||
@@ -167,6 +180,7 @@ class TestTpool(TestCase):
|
||||
opts,args = parser.parse_args(["-nfoo"])
|
||||
self.assertEqual(opts.n, 'foo')
|
||||
|
||||
@skip_with_libevent
|
||||
def test_contention(self):
|
||||
from tests import tpool_test
|
||||
prox = tpool.Proxy(tpool_test)
|
||||
@@ -179,12 +193,14 @@ class TestTpool(TestCase):
|
||||
for waiter in waiters:
|
||||
waiter.wait()
|
||||
|
||||
@skip_with_libevent
|
||||
def test_timeout(self):
|
||||
import time
|
||||
api.exc_after(0.1, api.TimeoutError())
|
||||
self.assertRaises(api.TimeoutError,
|
||||
tpool.execute, time.sleep, 0.3)
|
||||
|
||||
@skip_with_libevent
|
||||
def test_killall(self):
|
||||
tpool.killall()
|
||||
tpool.setup()
|
||||
|
Reference in New Issue
Block a user