Slight improvement to hide twisted tests from people who don't have it.

This commit is contained in:
Ryan Williams
2009-08-24 12:19:43 -07:00
parent 24f91bde15
commit a538c4a6b9
2 changed files with 6 additions and 2 deletions

View File

@@ -60,7 +60,10 @@ def requires_twisted(func):
""" Decorator that skips a test if Twisted is not present."""
def requirement(_f):
from eventlet.api import get_hub
return 'Twisted' in type(get_hub()).__name__
try:
return 'Twisted' in type(get_hub()).__name__
except Exception:
return False
return skip_unless_requirement(requirement)(func)

View File

@@ -93,6 +93,7 @@ class TestCase(unittest.TestCase):
def connector(self):
return pr.GreenClientCreator(reactor, self.gtransportClass, self.transportBufferSize)
@requires_twisted
def setUp(self):
port = self.setup_server()
self.conn = self.connector.connectTCP('127.0.0.1', port)