Jelajahi Sumber

Fixes functional test suite

Ask Solem 14 tahun lalu
induk
melakukan
6c46ca4bd4

+ 1 - 0
celery/tests/functional/case.py

@@ -52,6 +52,7 @@ class Worker(object):
             from celery import current_app
             current_app.worker_main(["celeryd", "--loglevel=DEBUG",
                                                 "-n", self.hostname])
+            os._exit(0)
         self.pid = pid
 
     def is_alive(self, timeout=1):

+ 4 - 0
funtests/setup.cfg

@@ -0,0 +1,4 @@
+[nosetests]
+verbosity = 1
+detailed-errors = 1
+where = suite

+ 66 - 0
funtests/setup.py

@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+try:
+    from setuptools import setup
+    from setuptools.command.install import install
+except ImportError:
+    from ez_setup import use_setuptools
+    use_setuptools()
+    from setuptools import setup
+    from setuptools.command.install import install
+
+import os
+import sys
+
+sys.path.insert(0, os.getcwd())
+sys.path.insert(0, os.path.join(os.getcwd(), os.pardir))
+import suite
+
+class no_install(install):
+
+    def run(self, *args, **kwargs):
+        import sys
+        sys.stderr.write("""
+------------------------------------------------------
+The Celery functional test suite cannot be installed.
+------------------------------------------------------
+
+
+But you can execute the tests by running the command:
+
+    $ python setup.py test
+
+
+""")
+
+
+setup(
+    name='celery-funtests',
+    version="DEV",
+    description="Functional test suite for Celery",
+    author="Ask Solem",
+    author_email="ask@celeryproject.org",
+    url="http://github.com/ask/celery",
+    platforms=["any"],
+    packages=[],
+    data_files=[],
+    zip_safe=False,
+    cmdclass={"install": no_install},
+    test_suite="nose.collector",
+    tests_require=[
+        "unittest2>=0.4.0",
+        "simplejson",
+        "nose",
+        "pytyrant",
+        "redis",
+        "pymongo",
+    ],
+    classifiers=[
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        "License :: OSI Approved :: BSD License",
+        "Intended Audience :: Developers",
+    ],
+    long_description="Do not install this package",
+)

+ 4 - 1
funtests/__init__.py → funtests/suite/__init__.py

@@ -1,7 +1,10 @@
 import os
+import sys
+
+sys.path.insert(0, os.path.join(os.getcwd(), os.pardir))
 
 config = os.environ.setdefault("CELERY_FUNTEST_CONFIG_MODULE",
-                               "celery.tests.functional.config")
+                               "suite.config")
 
 os.environ["CELERY_CONFIG_MODULE"] = config
 os.environ["CELERY_LOADER"] = "default"

+ 0 - 0
funtests/config.py → funtests/suite/config.py


+ 11 - 2
funtests/test_basic.py → funtests/suite/test_basic.py

@@ -1,12 +1,22 @@
 import operator
+import os
+import sys
 import time
 
+# funtest config
+sys.path.insert(0, os.getcwd())
+sys.path.insert(0, os.path.join(os.getcwd(), os.pardir))
+import suite
+
+from celery.tests.utils import unittest
 from celery.tests.functional import tasks
 from celery.tests.functional.case import WorkerCase
 
+
 from celery.task.control import broadcast
 
 
+
 class test_basic(WorkerCase):
 
     def test_started(self):
@@ -55,5 +65,4 @@ class test_basic(WorkerCase):
 
 
 if __name__ == "__main__":
-    from unittest2 import main
-    main()
+    unittest.main()

+ 0 - 2
funtests/test.cfg

@@ -1,2 +0,0 @@
-[nose]
-where = celery/tests/functional