Fix unit tests that may break under gevent
This commit is contained in:
7
setup.py
7
setup.py
@@ -15,13 +15,14 @@
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
import ez_setup
|
||||
ez_setup.use_setuptools()
|
||||
|
||||
if __name__ == '__main__' and sys.argv[1] == "gevent_nosetests":
|
||||
print("Running gevent tests")
|
||||
from gevent.monkey import patch_all
|
||||
patch_all()
|
||||
|
||||
import ez_setup
|
||||
ez_setup.use_setuptools()
|
||||
|
||||
from setuptools import setup
|
||||
from distutils.command.build_ext import build_ext
|
||||
from distutils.core import Extension
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import sys
|
||||
import six
|
||||
|
||||
try:
|
||||
@@ -42,6 +43,8 @@ class AsyncoreConnectionTest(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if 'gevent.monkey' in sys.modules:
|
||||
raise unittest.SkipTest("gevent monkey-patching detected")
|
||||
AsyncoreConnection.initialize_reactor()
|
||||
cls.socket_patcher = patch('socket.socket', spec=socket.socket)
|
||||
cls.mock_socket = cls.socket_patcher.start()
|
||||
|
@@ -11,7 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
@@ -19,6 +18,7 @@ except ImportError:
|
||||
|
||||
import errno
|
||||
import os
|
||||
import sys
|
||||
|
||||
import six
|
||||
from six import BytesIO
|
||||
@@ -48,6 +48,8 @@ except ImportError:
|
||||
class LibevConnectionTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
if 'gevent.monkey' in sys.modules:
|
||||
raise unittest.SkipTest("gevent monkey-patching detected")
|
||||
if LibevConnection is None:
|
||||
raise unittest.SkipTest('libev does not appear to be installed correctly')
|
||||
LibevConnection.initialize_reactor()
|
||||
|
Reference in New Issue
Block a user