Ver código fonte

Eventlet test failed if eventlet not installed

Ask Solem 14 anos atrás
pai
commit
a62f27110d
1 arquivos alterados com 6 adições e 9 exclusões
  1. 6 9
      celery/tests/test_concurrency_evlet.py

+ 6 - 9
celery/tests/test_concurrency_evlet.py

@@ -5,14 +5,11 @@ from celery.tests.utils import unittest
 from celery.tests.utils import patch
 
 
-monkey_patched = []
-
-
 class EventletCase(unittest.TestCase):
 
     def setUp(self):
         try:
-            __import__("eventlet")
+            self.eventlet = __import__("eventlet")
         except ImportError:
             raise SkipTest(
                 "eventlet not installed, skipping related tests.")
@@ -21,11 +18,10 @@ class EventletCase(unittest.TestCase):
 
 class test_eventlet_patch(EventletCase):
 
-    def setUp(self):
-        EventletCase.setUp(self)
-
-    @patch("eventlet", "monkey_patch", lambda: monkey_patched.append(True))
-    def test_is_patches(self):
+    def test_is_patched(self):
+        monkey_patched = []
+        prev_monkey_patch = self.eventlet.monkey_patch
+        self.eventlet.monkey_patch = lambda: monkey_patched.append(True)
         prev_evlet = sys.modules.pop("celery.concurrency.evlet", None)
         os.environ.pop("EVENTLET_NOPATCH")
         try:
@@ -35,3 +31,4 @@ class test_eventlet_patch(EventletCase):
         finally:
             sys.modules["celery.concurrency.evlet"] = prev_evlet
             os.environ["EVENTLET_NOPATCH"] = "yes"
+            self.eventlet.monkey_patch = prev_monkey_patch