Ask Solem 11 years ago
parent
commit
46dc4c968b
4 changed files with 17 additions and 10 deletions
  1. 1 1
      celery/__init__.py
  2. 0 2
      celery/task/__init__.py
  3. 3 1
      celery/tests/bin/test_beat.py
  4. 13 6
      celery/tests/case.py

+ 1 - 1
celery/__init__.py

@@ -123,7 +123,7 @@ if sys.version_info[0:2] == (3, 2):
                 if '.' in name:
                     modname, path = name.split('.')[-1], __path__
                 module_info = imp.find_module(modname, path)
-                module = imp.load_module(name, *module_info)
+                imp.load_module(name, *module_info)
                 return sys.modules[name]
 
         def find_module(self, name, path):

+ 0 - 2
celery/task/__init__.py

@@ -15,8 +15,6 @@ from celery._state import current_app, current_task as current
 from celery.five import MagicModule, recreate_module
 from celery.local import Proxy
 
-print("IMPORTING TASK")
-
 __all__ = [
     'BaseTask', 'Task', 'PeriodicTask', 'task', 'periodic_task',
     'group', 'chord', 'subtask', 'TaskSet',

+ 3 - 1
celery/tests/bin/test_beat.py

@@ -133,7 +133,9 @@ class test_Beat(AppCase):
     @patch('celery.apps.beat.logger')
     def test_logs_errors(self, logger, stdout, stderr):
         with restore_logging():
-            b = MockBeat3(app=self.app, redirect_stdouts=False, socket_timeout=None)
+            b = MockBeat3(
+                app=self.app, redirect_stdouts=False, socket_timeout=None,
+            )
             b.start_scheduler()
             self.assertTrue(logger.critical.called)
 

+ 13 - 6
celery/tests/case.py

@@ -63,6 +63,15 @@ CASE_REDEFINES_TEARDOWN = """\
 {name} (subclass of AppCase) redefines private "tearDown", \
 should be: "teardown"\
 """
+CASE_LOG_REDIRECT_EFFECT = """\
+Test {0} did not disable LoggingProxy for {1}\
+"""
+CASE_LOG_LEVEL_EFFECT = """\
+Test {0} Modified the level of the root logger\
+"""
+CASE_LOG_HANDLER_EFFECT = """\
+Test {0} Modified handlers for the root logger\
+"""
 
 CELERY_TEST_CONFIG = {
     #: Don't want log output when running suite.
@@ -328,12 +337,10 @@ class AppCase(Case):
         this = self._get_test_name()
         if isinstance(sys.stdout, LoggingProxy) or \
                 isinstance(sys.__stdout__, LoggingProxy):
-            raise RuntimeError(
-                'Test {0} did not disable LoggingProxy for stdout'.format(this))
+            raise RuntimeError(CASE_LOG_REDIRECT_EFFECT.format(this, 'stdout'))
         if isinstance(sys.stderr, LoggingProxy) or \
                 isinstance(sys.__stderr__, LoggingProxy):
-            raise RuntimeError(
-                'Test {0} did not disable LoggingProxy for stderr'.format(this))
+            raise RuntimeError(CASE_LOG_REDIRECT_EFFECT.format(this, 'stderr'))
         backend = self.app.__dict__.get('backend')
         if backend is not None:
             if isinstance(backend, CacheBackend):
@@ -361,9 +368,9 @@ class AppCase(Case):
         this = self._get_test_name()
         root = logging.getLogger()
         if root.level != self.__rootlevel:
-            raise RuntimeError('Test {0} changed root loglevel'.format(this))
+            raise RuntimeError(CASE_LOG_LEVEL_EFFECT.format(this))
         if root.handlers != self.__roothandlers:
-            raise RuntimeError('Test {0} changed root handlers'.format(this))
+            raise RuntimeError(CASE_LOG_HANDLER_EFFECT.format(this))
 
     def setup(self):
         pass