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