|
19 | 19 | import unittest # noqa |
20 | 20 |
|
21 | 21 | from tests.unit.io.utils import TimerConnectionTests |
22 | | -from tests.unit.io.eventlet_utils import restore_saved_module |
23 | | -from tests import notpypy |
24 | | -from tests import notmonkeypatch |
| 22 | +from tests import notpypy, MONKEY_PATCH_LOOP, notmonkeypatch |
25 | 23 |
|
26 | | -import time |
27 | | -from eventlet import monkey_patch, kill |
| 24 | +from eventlet import monkey_patch |
28 | 25 |
|
29 | 26 | try: |
30 | 27 | from cassandra.io.eventletreactor import EventletConnection |
31 | 28 | except ImportError: |
32 | 29 | EventletConnection = None # noqa |
33 | 30 |
|
34 | | -@unittest.skipUnless(EventletConnection is not None, "Skpping the eventlet tests because it's not installed") |
35 | | -@notmonkeypatch |
36 | 31 | # There are some issues with some versions of pypy and eventlet |
37 | 32 | @notpypy |
| 33 | +@unittest.skipIf(EventletConnection is None, "Skpping the eventlet tests because it's not installed") |
| 34 | +@notmonkeypatch |
38 | 35 | class EventletTimerTest(unittest.TestCase, TimerConnectionTests): |
39 | | - |
40 | | - def setUp(self): |
41 | | - self.connection_class = EventletConnection |
42 | | - # We only to patch the time module |
43 | | - monkey_patch(time=True) |
| 36 | + @classmethod |
| 37 | + def setUpClass(cls): |
| 38 | + # This is run even though the class is skipped, so we need |
| 39 | + # to make sure no monkey patching is happening |
| 40 | + if not MONKEY_PATCH_LOOP: |
| 41 | + return |
| 42 | + monkey_patch() |
| 43 | + cls.connection_class = EventletConnection |
44 | 44 | EventletConnection.initialize_reactor() |
45 | 45 |
|
46 | | - def tearDown(self): |
47 | | - kill(EventletConnection._timeout_watcher) |
48 | | - EventletConnection._timers = None |
49 | | - restore_saved_module(time) |
| 46 | + # There is no unpatching because there is not a clear way |
| 47 | + # of doing it reliably |
0 commit comments