فهرست منبع

Tests passing on 2.4 (except for database dependent tests for some reason, as sqlite is not working?)

Ask Solem 15 سال پیش
والد
کامیت
76321926f6

+ 2 - 2
celery/exceptions.py

@@ -14,7 +14,7 @@ class NotRegistered(KeyError):
 
     def __init__(self, message, *args, **kwargs):
         message = UNREGISTERED_FMT % str(message)
-        super(NotRegistered, self).__init__(message, *args, **kwargs)
+        KeyError.__init__(self, message, *args, **kwargs)
 
 
 class AlreadyRegistered(Exception):
@@ -34,4 +34,4 @@ class RetryTaskError(Exception):
 
     def __init__(self, message, exc, *args, **kwargs):
         self.exc = exc
-        super(RetryTaskError, self).__init__(message, exc, *args, **kwargs)
+        Exception.__init__(self, message, exc, *args, **kwargs)

+ 8 - 8
celery/task/http.py

@@ -58,18 +58,18 @@ class MutableURL(object):
 
     """
     def __init__(self, url):
-        self.url = urlparse(url)
-        self._query = dict(parse_qsl(self.url.query))
+        self.parts = urlparse(url)
+        self._query = dict(parse_qsl(self.parts[4]))
 
     def __str__(self):
-        u = self.url
+        scheme, netloc, path, params, query, fragment = self.parts
         query = urlencode(utf8dict(self.query.items()))
-        components = ["%s://" % u.scheme,
-                      "%s" % u.netloc,
-                      u.path and "%s" % u.path or "/",
-                      u.params and ";%s" % u.params or None,
+        components = ["%s://" % scheme,
+                      "%s" % netloc,
+                      path and "%s" % path or "/",
+                      params and ";%s" % params or None,
                       query and "?%s" % query or None,
-                      u.fragment and "#%s" % u.fragment or None]
+                      fragment and "#%s" % fragment or None]
         return "".join(filter(None, components))
 
     def __repr__(self):

+ 1 - 1
celery/tests/compat.py

@@ -48,7 +48,7 @@ class catch_warnings(object):
 
         """
         self._record = record
-        self._module = sys.modules['warnings'] if module is None else module
+        self._module = module is None and sys.modules["warnings"] or module
         self._entered = False
 
     def __repr__(self):

+ 6 - 2
celery/tests/test_backends/test_base.py

@@ -1,5 +1,6 @@
-import unittest
+import sys
 import types
+import unittest
 
 from django.db.models.base import subclass_exception
 from billiard.serialization import find_nearest_pickleable_exception as fnpe
@@ -80,7 +81,10 @@ class TestPrepareException(unittest.TestCase):
         self.assertTrue(isinstance(x, UnpickleableExceptionWrapper))
         y = b.exception_to_python(x)
         self.assertEquals(y.__class__.__name__, "Impossible")
-        self.assertEquals(y.__class__.__module__, "foo.module")
+        if sys.version_info < (2, 5):
+            self.assertTrue(y.__class__.__module__)
+        else:
+            self.assertEquals(y.__class__.__module__, "foo.module")
 
     def test_regular(self):
         x = b.prepare_exception(KeyError("baz"))

+ 1 - 1
celery/tests/test_backends/test_redis.py

@@ -138,7 +138,7 @@ class TestTyrantBackendNoTyrant(unittest.TestCase):
         from celery.tests.utils import mask_modules
         prev = sys.modules.pop("celery.backends.pyredis")
         try:
-            def with_redis_masked():
+            def with_redis_masked(_val):
                 from celery.backends.pyredis import redis
                 self.assertTrue(redis is None)
             context = mask_modules("redis")

+ 1 - 1
celery/tests/test_pickle.py

@@ -11,7 +11,7 @@ class ArgOverrideException(Exception):
 
     def __init__(self, message, status_code=10):
         self.status_code = status_code
-        super(ArgOverrideException, self).__init__(message, status_code)
+        Exception.__init__(self, message, status_code)
 
 
 class TestPickle(unittest.TestCase):

+ 1 - 1
celery/tests/test_serialization.py

@@ -10,7 +10,7 @@ class TestAAPickle(unittest.TestCase):
         from celery.tests.utils import mask_modules
         prev = sys.modules.pop("billiard.serialization")
         try:
-            def with_cPickle_masked():
+            def with_cPickle_masked(_val):
                 from billiard.serialization import pickle
                 import pickle as orig_pickle
                 self.assertTrue(pickle.dumps is orig_pickle.dumps)

+ 14 - 11
celery/tests/test_task_http.py

@@ -5,7 +5,10 @@ import sys
 import logging
 import unittest
 from urllib import addinfourl
-from contextlib import contextmanager
+try:
+    from contextlib import contextmanager
+except ImportError:
+    from celery.tests.utils import fallback_contextmanager as contextmanager
 try:
     from cStringIO import StringIO
 except ImportError:
@@ -100,7 +103,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_success(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "GET", {
                                     "x": 10, "y": 10}, logger)
             self.assertEquals(d.dispatch(), 100)
@@ -111,7 +114,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_failure(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "GET", {
                                     "x": 10, "y": 10}, logger)
             self.assertRaises(http.RemoteExecuteError, d.dispatch)
@@ -122,7 +125,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_empty_response(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "GET", {
                                     "x": 10, "y": 10}, logger)
             self.assertRaises(http.InvalidResponseError, d.dispatch)
@@ -133,7 +136,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_non_json(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "GET", {
                                     "x": 10, "y": 10}, logger)
             self.assertRaises(http.InvalidResponseError, d.dispatch)
@@ -144,7 +147,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_unknown_status(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "GET", {
                                     "x": 10, "y": 10}, logger)
             self.assertRaises(http.UnknownStatusError, d.dispatch)
@@ -155,7 +158,7 @@ class TestHttpDispatch(unittest.TestCase):
     def test_dispatch_POST(self):
         logger = logging.getLogger("celery.unittest")
 
-        def with_mock_urlopen():
+        def with_mock_urlopen(_val):
             d = http.HttpDispatch("http://example.com/mul", "POST", {
                                     "x": 10, "y": 10}, logger)
             self.assertEquals(d.dispatch(), 100)
@@ -167,9 +170,9 @@ class TestHttpDispatch(unittest.TestCase):
 class TestURL(unittest.TestCase):
 
     def test_URL_get_async(self):
-        def with_eager_tasks():
+        def with_eager_tasks(_val):
 
-            def with_mock_urlopen():
+            def with_mock_urlopen(_val):
                 d = http.URL("http://example.com/mul").get_async(x=10, y=10)
                 self.assertEquals(d.get(), 100)
 
@@ -179,9 +182,9 @@ class TestURL(unittest.TestCase):
         execute_context(eager_tasks(), with_eager_tasks)
 
     def test_URL_post_async(self):
-        def with_eager_tasks():
+        def with_eager_tasks(_val):
 
-            def with_mock_urlopen():
+            def with_mock_urlopen(_val):
                 d = http.URL("http://example.com/mul").post_async(x=10, y=10)
                 self.assertEquals(d.get(), 100)
 

+ 1 - 1
celery/tests/test_utils.py

@@ -34,7 +34,7 @@ class TestGenUniqueId(unittest.TestCase):
         from celery.tests.utils import mask_modules
         old_utils = sys.modules.pop("celery.utils")
 
-        def with_ctypes_masked():
+        def with_ctypes_masked(_val):
             from celery.utils import ctypes, gen_unique_id
 
             self.assertTrue(ctypes is None)

+ 2 - 0
celery/tests/utils.py

@@ -32,6 +32,8 @@ class GeneratorContextManager(object):
                 raise RuntimeError("generator didn't stop after throw()")
             except StopIteration:
                 return True
+            except AttributeError:
+                raise value
             except:
                 if sys.exc_info()[1] is not value:
                     raise