Commit 2a4e2c28 authored by Jason Madden's avatar Jason Madden

Make zope.interface optional for tests too.

parent 3b630a0a
...@@ -145,3 +145,18 @@ except ImportError: # Python 2 ...@@ -145,3 +145,18 @@ except ImportError: # Python 2
return unittest.skip(reason) return unittest.skip(reason)
mock = mock mock = mock
# zope.interface
try:
from zope.interface import verify
except ImportError:
class verify(object):
@staticmethod
def verifyObject(*_):
import warnings
warnings.warn("zope.interface is not installed; not verifying")
return
verify = verify
...@@ -146,7 +146,7 @@ def skipWithoutPSUtil(reason): ...@@ -146,7 +146,7 @@ def skipWithoutPSUtil(reason):
# Python 2 # Python 2
pass pass
test_item = SkipWrapper test_item = SkipWrapper
print(test_item.mro())
return test_item return test_item
return decorator return decorator
......
...@@ -10,8 +10,8 @@ from greenlet import settrace ...@@ -10,8 +10,8 @@ from greenlet import settrace
from gevent.monkey import get_original from gevent.monkey import get_original
from gevent._compat import thread_mod_name from gevent._compat import thread_mod_name
from gevent._compat import NativeStrIO from gevent._compat import NativeStrIO
from gevent._compat import get_this_psutil_process
from gevent.testing import verify
from gevent.testing.skipping import skipWithoutPSUtil from gevent.testing.skipping import skipWithoutPSUtil
from gevent import _monitor as monitor from gevent import _monitor as monitor
...@@ -247,7 +247,6 @@ class TestPeriodicMonitorBlocking(_AbstractTestPeriodicMonitoringThread, ...@@ -247,7 +247,6 @@ class TestPeriodicMonitorBlocking(_AbstractTestPeriodicMonitoringThread,
# so nothing is considered blocked # so nothing is considered blocked
from gevent.events import subscribers from gevent.events import subscribers
from gevent.events import IEventLoopBlocked from gevent.events import IEventLoopBlocked
from zope.interface.verify import verifyObject
events = [] events = []
subscribers.append(events.append) subscribers.append(events.append)
...@@ -265,7 +264,7 @@ class TestPeriodicMonitorBlocking(_AbstractTestPeriodicMonitoringThread, ...@@ -265,7 +264,7 @@ class TestPeriodicMonitorBlocking(_AbstractTestPeriodicMonitoringThread,
# Again without switching is a problem. # Again without switching is a problem.
self.assertTrue(self.pmt.monitor_blocking(self.hub)) self.assertTrue(self.pmt.monitor_blocking(self.hub))
self.assertTrue(events) self.assertTrue(events)
verifyObject(IEventLoopBlocked, events[0]) verify.verifyObject(IEventLoopBlocked, events[0])
del events[:] del events[:]
# But we can order it not to be a problem # But we can order it not to be a problem
......
...@@ -8,8 +8,19 @@ from __future__ import print_function ...@@ -8,8 +8,19 @@ from __future__ import print_function
import unittest import unittest
from gevent import events from gevent import events
from zope.interface import verify
try:
from zope.interface import verify
except ImportError:
verify = None
try:
from zope import event
except ImportError:
event = None
@unittest.skipIf(verify is None, "Needs zope.interface")
class TestImplements(unittest.TestCase): class TestImplements(unittest.TestCase):
def test_event_loop_blocked(self): def test_event_loop_blocked(self):
...@@ -28,10 +39,10 @@ class TestImplements(unittest.TestCase): ...@@ -28,10 +39,10 @@ class TestImplements(unittest.TestCase):
events.MemoryUsageUnderThreshold(0, 0, 0, 0)) events.MemoryUsageUnderThreshold(0, 0, 0, 0))
@unittest.skipIf(event is None, "Needs zope.event")
class TestEvents(unittest.TestCase): class TestEvents(unittest.TestCase):
def test_is_zope(self): def test_is_zope(self):
from zope import event
self.assertIs(events.subscribers, event.subscribers) self.assertIs(events.subscribers, event.subscribers)
self.assertIs(events.notify, event.notify) self.assertIs(events.notify, event.notify)
......
...@@ -329,7 +329,7 @@ class TestPeriodicMonitoringThread(greentest.TestCase): ...@@ -329,7 +329,7 @@ class TestPeriodicMonitoringThread(greentest.TestCase):
class TestLoopInterface(unittest.TestCase): class TestLoopInterface(unittest.TestCase):
def test_implemensts_ILoop(self): def test_implemensts_ILoop(self):
from zope.interface import verify from gevent.testing import verify
from gevent._interfaces import ILoop from gevent._interfaces import ILoop
loop = get_hub().loop loop = get_hub().loop
......
...@@ -70,7 +70,7 @@ class TestMonkey(SubscriberCleanupMixin, unittest.TestCase): ...@@ -70,7 +70,7 @@ class TestMonkey(SubscriberCleanupMixin, unittest.TestCase):
def test_patch_twice_warnings_events(self): def test_patch_twice_warnings_events(self):
import warnings import warnings
from zope.interface import verify from gevent.testing import verify
orig_saved = {} orig_saved = {}
for k, v in monkey.saved.items(): for k, v in monkey.saved.items():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment