Browse Source

All tests are passing without Django installed!

Ask Solem 15 years ago
parent
commit
2d5af80403

+ 0 - 2
celery/loaders/__init__.py

@@ -7,8 +7,6 @@ from carrot.utils import rpartition
 from celery.utils import get_full_cls_name, first
 from celery.loaders.default import Loader as DefaultLoader
 
-#from djcelery.loaders.djangoapp import Loader as DjangoLoader
-
 _DEFAULT_LOADER_CLASS_NAME = "Loader"
 LOADER_ALIASES = {"default": "celery.loaders.default.Loader",
                   "django": "djcelery.loaders.djangoapp.Loader"}

+ 0 - 20
docs/internals/moduleindex.rst

@@ -98,23 +98,6 @@ Messaging
 celery.messaging
 ----------------
 
-Django-specific
-===============
-
-celery.models
--------------
-
-celery.managers
----------------
-
-celery.views
-------------
-
-celery.urls
------------
-
-celery.management
-
 Result backends
 ===============
 
@@ -145,9 +128,6 @@ celery.loaders.base - Loader base classes
 celery.loaders.default - The default loader
 -------------------------------------------
 
-celery.loaders.djangoapp - The Django loader
---------------------------------------------
-
 CeleryBeat
 ==========
 

+ 1 - 2
docs/reference/celery.conf.rst

@@ -143,8 +143,7 @@ Configuration - celery.conf
 
 .. data:: CELERY_CACHE_BACKEND
 
-    Use a custom cache backend for celery. If not set the django-global
-    cache backend in ``CACHE_BACKEND`` will be used.
+    Celery cache backend.
 
 .. data:: SEND_EVENTS
 

+ 7 - 0
setup.cfg

@@ -1,3 +1,10 @@
+[nosetests]
+where = celery/tests
+cover3-branch = 1
+cover3-html = 1
+cover3-package = celery
+cover3-exclude = celery.__init__,celery.conf,celery.tests.*,celery.bin.celerybeat,celery.utils.patch,celery.utils.compat,celery.task.rest,celery.platform,celery.backends.mongodb,celery.backends.tyrant
+
 [build_sphinx]
 source-dir = docs/
 build-dir = docs/.build

+ 10 - 24
setup.py

@@ -7,41 +7,26 @@ import platform
 
 try:
     from setuptools import setup, find_packages, Command
+    from setuptools.command.test import test as TestCommand
 except ImportError:
     from ez_setup import use_setuptools
     use_setuptools()
     from setuptools import setup, find_packages, Command
+    from setuptools.command.test import test as TestCommand
 
 import celery as distmeta
 
 
-class RunTests(Command):
-    description = "Run the django test suite from the tests dir."
-    user_options = []
+class RunTests(TestCommand):
+    env = dict(CELERY_LOADER="default",
+               CELERY_CONFIG_MODULE="tests.celeryconfig",
+               CELERYINIT=1)
     extra_env = {}
 
-    def run(self):
-        for env_name, env_value in self.extra_env.items():
+    def run(self, *args, **kwargs):
+        for env_name, env_value in dict(self.env, **self.extra_env).items():
             os.environ[env_name] = str(env_value)
-
-        this_dir = os.getcwd()
-        testproj_dir = os.path.join(this_dir, "tests")
-        os.chdir(testproj_dir)
-        sys.path.append(testproj_dir)
-        from django.core.management import execute_manager
-        os.environ["DJANGO_SETTINGS_MODULE"] = os.environ.get(
-                        "DJANGO_SETTINGS_MODULE", "settings")
-        settings_file = os.environ["DJANGO_SETTINGS_MODULE"]
-        settings_mod = __import__(settings_file, {}, {}, [''])
-        execute_manager(settings_mod, argv=[
-            __file__, "test"])
-        os.chdir(this_dir)
-
-    def initialize_options(self):
-        pass
-
-    def finalize_options(self):
-        pass
+        TestCommand.run(self, *args, **kwargs)
 
 
 class QuickRunTests(RunTests):
@@ -89,6 +74,7 @@ setup(
     zip_safe=False,
     install_requires=install_requires,
     cmdclass = {"test": RunTests, "quicktest": QuickRunTests},
+    test_suite="nose.collector",
     classifiers=[
         "Development Status :: 5 - Production/Stable",
         "Framework :: Django",

+ 9 - 0
tests/celeryconfig.py

@@ -0,0 +1,9 @@
+BROKER_HOST = "localhost"
+BROKER_PORT = 5672
+BROKER_USER = "guest"
+BROKER_PASSWORD = "guest"
+BROKER_VHOST = "/"
+
+CELERY_RESULT_BACKEND = "database"
+CELERY_RESULT_DBURI = "sqlite:///:memory:"
+CELERY_SEND_TASK_ERROR_EMAILS = False

+ 0 - 16
tests/manage.py

@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-from django.core.management import execute_manager
-try:
-    import settings # Assumed to be in the same directory.
-except ImportError:
-    import sys
-    sys.stderr.write(
-            "Error: Can't find the file 'settings.py' in the directory \
-            containing %r. It appears you've customized things.\n\
-            You'll have to run django-admin.py, passing it your settings\
-            module.\n(If the file settings.py does indeed exist, it's\
-            causing an ImportError somehow.)\n" % __file__)
-    sys.exit(1)
-
-if __name__ == "__main__":
-    execute_manager(settings)

+ 0 - 78
tests/settings.py

@@ -1,78 +0,0 @@
-# Django settings for testproj project.
-
-import os
-import sys
-# import source code dir
-sys.path.insert(0, os.getcwd())
-sys.path.insert(0, os.path.join(os.getcwd(), os.pardir))
-
-SITE_ID = 300
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-ROOT_URLCONF = "tests.urls"
-
-ADMINS = (
-    # ('Your Name', 'your_email@domain.com'),
-)
-
-TEST_RUNNER = "django_nose.run_tests"
-here = os.path.abspath(os.path.dirname(__file__))
-COVERAGE_EXCLUDE_MODULES = ("celery.__init__",
-                            "celery.conf",
-                            "celery.tests.*",
-                            "celery.management.*",
-                            "celery.contrib.*",
-                            "celery.bin.celeryinit",
-                            "celery.bin.celerybeat",
-                            "celery.utils.patch",
-                            "celery.utils.compat",
-                            "celery.task.rest",
-                            "celery.platform", # FIXME
-                            "celery.backends.mongodb", # FIXME
-                            "celery.backends.tyrant", # FIXME
-)
-
-NOSE_ARGS = [os.path.join(here, os.pardir, "celery", "tests"),
-            os.environ.get("NOSE_VERBOSE") and "--verbose" or "",
-            "--cover3-package=celery",
-            "--cover3-branch",
-            "--cover3-exclude=%s" % ",".join(COVERAGE_EXCLUDE_MODULES)]
-
-BROKER_HOST = "localhost"
-BROKER_PORT = 5672
-BROKER_VHOST = "/"
-BROKER_USER = "guest"
-BROKER_PASSWORD = "guest"
-
-TT_HOST = "localhost"
-TT_PORT = 1978
-
-CELERY_DEFAULT_EXCHANGE = "testcelery"
-CELERY_DEFAULT_ROUTING_KEY = "testcelery"
-CELERY_DEFAULT_QUEUE = "testcelery"
-
-CELERY_QUEUES = {"testcelery": {"binding_key": "testcelery"}}
-
-MANAGERS = ADMINS
-
-DATABASE_ENGINE = 'sqlite3'
-DATABASE_NAME = ':memory'
-DATABASE_USER = ''
-DATABASE_PASSWORD = ''
-DATABASE_HOST = ''
-DATABASE_PORT = ''
-
-INSTALLED_APPS = (
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.sessions',
-    'django.contrib.sites',
-    'django_nose',
-    'djcelery',
-    'someapp',
-    'someappwotask',
-)
-
-CELERY_SEND_TASK_ERROR_EMAILS = False

+ 0 - 0
tests/someapp/__init__.py


+ 0 - 3
tests/someapp/models.py

@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.

+ 0 - 8
tests/someapp/tasks.py

@@ -1,8 +0,0 @@
-from celery.task import tasks, Task
-
-
-class SomeAppTask(Task):
-    name = "c.unittest.SomeAppTask"
-
-    def run(self, **kwargs):
-        return 42

+ 0 - 1
tests/someapp/views.py

@@ -1 +0,0 @@
-# Create your views here.

+ 0 - 0
tests/someappwotask/__init__.py


+ 0 - 3
tests/someappwotask/models.py

@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.

+ 0 - 1
tests/someappwotask/views.py

@@ -1 +0,0 @@
-# Create your views here.

+ 0 - 22
tests/urls.py

@@ -1,22 +0,0 @@
-from django.conf.urls.defaults import (patterns, url, include,
-                                       handler500, handler404)
-from djcelery.views import apply
-
-# Uncomment the next two lines to enable the admin:
-# from django.contrib import admin
-# admin.autodiscover()
-
-urlpatterns = patterns('',
-    # Example:
-    # (r'^tests/', include('tests.foo.urls')),
-
-    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
-    # to INSTALLED_APPS to enable admin documentation:
-    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
-    # Uncomment the next line to enable the admin:
-    # (r'^admin/(.*)', admin.site.root),
-    url(r"^apply/(?P<task_name>.+?)/", apply, name="celery-apply"),
-    url(r"^celery/", include("djcelery.urls")),
-
-)